kliment-olechnovic / voronota

Voronota is a software tool for analyzing three-dimensional structures of biological macromolecules using the Voronoi diagram of atomic balls.
https://kliment-olechnovic.github.io/voronota/
MIT License
25 stars 3 forks source link

Conditionally include expansions #3

Closed merkys closed 1 year ago

merkys commented 1 year ago

Current layout of CMakeLists.txt files (one in base directory and one in each of extensions) is convenient, but cannot be easily handled by Debian build tools. Thus to build for Debian I have to modify the main CMakeLists.txt:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,5 +8,8 @@

 add_executable(voronota ${VORONOTA_SRC})

+add_subdirectory(expansion_gl)
+add_subdirectory(expansion_js)
+
 install(TARGETS voronota RUNTIME DESTINATION bin)
 install(PROGRAMS voronota-cadscore voronota-contacts voronota-resources voronota-voromqa voronota-volumes voronota-pocket voronota-membrane DESTINATION bin)

Many CMake-based projects I encounter use conditional includes for expansion directories. Maybe this could be done here? Then users wanting to build expansion_gl would run, for example:

$ cmake .. -DEXPANSION_GL=ON

If this is fine, I could come up with a pull request implementing it.

kliment-olechnovic commented 1 year ago

Hi,

Thanks for the suggestion. I think "conditionally including" expansions may indeed be convenient. I am not sure it will work with only few easy modifications, but the only way to know is to try.

So far "expansion_js" and "expansion_gl" are treated as separate applications that use the core Voronota code and resources, hence the separate CMakeLists.txt files and separate compilation. If I understood correctly, you proposal will eliminate the need to do additional cmake runs for every expansion, but still leave the possibility to compile every expansion separately? If, so this is a very good non-intrusive modification. If you have time to do it, I would be grateful.

merkys commented 1 year ago

Thanks for the suggestion. I think "conditionally including" expansions may indeed be convenient. I am not sure it will work with only few easy modifications, but the only way to know is to try.

From what I have seen, conditional include in CMakeLists.txt should be as simple as:

if(EXPANSION_GL)
    add_subdirectory(expansion_gl)
endif(EXPANSION_GL)

I have not tried that out yet, but will try.

So far "expansion_js" and "expansion_gl" are treated as separate applications that use the core Voronota code and resources, hence the separate CMakeLists.txt files and separate compilation. If I understood correctly, you proposal will eliminate the need to do additional cmake runs for every expansion, but still leave the possibility to compile every expansion separately? If, so this is a very good non-intrusive modification. If you have time to do it, I would be grateful.

Yes, the possibility to compile separately would remain as before, but people willing to compile/install everything at once would be given such possibility.

merkys commented 1 year ago

I have tested the described method and it seems to work as expected, without affecting the original intention to have separate CMake files. I have opened pull request #4.