htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 36e1db7263e48aeb1081402ba026ef1dfa81744e
parent 29b9570811dba1531756346b501338f73dc608e6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 30 Jun 2021 14:38:08 +0200

Merge branch 'feature_conditional_build' into develop

Diffstat:
Mcmake/CMakeLists.txt | 21+++++++++++++++++++--
Mcmake/commands/CMakeLists.txt | 31+++++++++++++++++++++++--------
Mcmake/doc/CMakeLists.txt | 15++++++++++-----
Msrc/commands/htrdr_atmosphere_cmd.c | 13++++++++++++-
Msrc/commands/htrdr_cmd.c | 31++++++++++++++++++++++++++-----
Msrc/commands/htrdr_combustion_cmd.c | 13++++++++++++-
6 files changed, 102 insertions(+), 22 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -27,13 +27,30 @@ set(VERSION_MINOR 7) set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) +option(HTRDR_BUILD_ATMOSPHERE "Build the htrdr-atmosphere program" ON) +option(HTRDR_BUILD_COMBUSTION "Build the htrdr-combustion program" ON) + +set(HTRDR_BUILD_COMMANDS "") +if(HTRDR_BUILD_ATMOSPHERE) + set(HTRDR_BUILD_COMMANDS "${HTRDR_BUILD_COMMANDS};HTRDR_BUILD_ATMOSPHERE") +endif() +if(HTRDR_BUILD_COMBUSTION) + set(HTRDR_BUILD_COMMANDS "${HTRDR_BUILD_COMMANDS};HTRDR_BUILD_COMBUSTION") +endif() + ################################################################################ # Add sub projects ################################################################################ add_subdirectory(core) -add_subdirectory(atmosphere) + +if(HTRDR_BUILD_ATMOSPHERE) + add_subdirectory(atmosphere) +endif() +if(HTRDR_BUILD_COMBUSTION) + add_subdirectory(combustion) +endif() + add_subdirectory(commands) -add_subdirectory(combustion) add_subdirectory(doc) ################################################################################ diff --git a/cmake/commands/CMakeLists.txt b/cmake/commands/CMakeLists.txt @@ -20,6 +20,15 @@ project(htrdr-commands C) include_directories(${HTRDR_BUILD_DIR} ${HTRDR_SOURCE_DIR}) +set(_link_libraries "") + +if(HTRDR_BUILD_ATMOSPHERE) + list(APPEND _link_libraries htrdr-atmosphere) +endif() +if(HTRDR_BUILD_COMBUSTION) + list(APPEND _link_libraries htrdr-combustion) +endif() + ################################################################################ # Check dependencies ################################################################################ @@ -30,21 +39,28 @@ include_directories(${RSys_INCLUDE_DIR}) # Configure and define targets ################################################################################ add_executable(htrdr_cmd ${HTRDR_SOURCE_DIR}/commands/htrdr_cmd.c) -target_link_libraries(htrdr_cmd htrdr-atmosphere htrdr-combustion) +target_link_libraries(htrdr_cmd ${_link_libraries}) set_target_properties(htrdr_cmd PROPERTIES + COMPILE_DEFINITIONS "${HTRDR_BUILD_COMMANDS}" OUTPUT_NAME htrdr) -add_executable(htrdr_atmosphere_cmd +add_executable(htrdr_atmosphere_cmd ${HTRDR_SOURCE_DIR}/commands/htrdr_atmosphere_cmd.c) -target_link_libraries(htrdr_atmosphere_cmd htrdr-atmosphere) -set_target_properties(htrdr_atmosphere_cmd PROPERTIES +set_target_properties(htrdr_atmosphere_cmd PROPERTIES + COMPILE_DEFINITIONS "${HTRDR_BUILD_COMMANDS}" OUTPUT_NAME htrdr-atmosphere) +if(HTRDR_BUILD_ATMOSPHERE) + target_link_libraries(htrdr_atmosphere_cmd htrdr-atmosphere) +endif() -add_executable(htrdr_combustion_cmd +add_executable(htrdr_combustion_cmd ${HTRDR_SOURCE_DIR}/commands/htrdr_combustion_cmd.c) -target_link_libraries(htrdr_combustion_cmd htrdr-combustion) -set_target_properties(htrdr_combustion_cmd PROPERTIES +set_target_properties(htrdr_combustion_cmd PROPERTIES + COMPILE_DEFINITIONS "${HTRDR_BUILD_COMMANDS}" OUTPUT_NAME htrdr-combustion) +if(HTRDR_BUILD_COMBUSTION) + target_link_libraries(htrdr_combustion_cmd htrdr-combustion) +endif() ################################################################################ # Define output & install directories @@ -53,4 +69,3 @@ install(TARGETS htrdr_cmd htrdr_atmosphere_cmd htrdr_combustion_cmd ARCHIVE DESTINATION bin LIBRARY DESTINATION lib RUNTIME DESTINATION bin) - diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt @@ -47,12 +47,17 @@ foreach(_name IN LISTS MAN_NAMES) endforeach() add_custom_target(man-copy ALL DEPENDS ${MAN_FILES}) -configure_file(${HTRDR_SOURCE_DIR}/../doc/htrdr-atmosphere.1.txt.in - ${CMAKE_CURRENT_BINARY_DIR}/htrdr-atmosphere.1.txt @ONLY) -configure_file(${HTRDR_SOURCE_DIR}/../doc/htrdr-combustion.1.txt.in - ${CMAKE_CURRENT_BINARY_DIR}/htrdr-combustion.1.txt @ONLY) +if(HTRDR_BUILD_ATMOSPHERE) + configure_file(${HTRDR_SOURCE_DIR}/../doc/htrdr-atmosphere.1.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/htrdr-atmosphere.1.txt @ONLY) + list(APPEND MAN_NAMES htrdr-atmosphere.1) +endif() -list(APPEND MAN_NAMES htrdr-atmosphere.1 htrdr-combustion.1) +if(HTRDR_BUILD_COMBUSTION) + configure_file(${HTRDR_SOURCE_DIR}/../doc/htrdr-combustion.1.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/htrdr-combustion.1.txt @ONLY) + list(APPEND MAN_NAMES htrdr-combustion.1) +endif() ################################################################################ # ROFF man pages diff --git a/src/commands/htrdr_atmosphere_cmd.c b/src/commands/htrdr_atmosphere_cmd.c @@ -15,10 +15,21 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "atmosphere/htrdr_atmosphere.h" +#ifdef HTRDR_BUILD_ATMOSPHERE + #include "atmosphere/htrdr_atmosphere.h" +#else + #include <stdio.h> +#endif int main(int argc, char** argv) { +#ifdef HTRDR_BUILD_ATMOSPHERE return htrdr_atmosphere_main(argc, argv); +#else + (void)argc, (void)argv; + fprintf(stderr, + "The htrdr-atmosphere command is not available in this htrdr build.\n"); + return 1; +#endif } diff --git a/src/commands/htrdr_cmd.c b/src/commands/htrdr_cmd.c @@ -15,10 +15,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "atmosphere/htrdr_atmosphere.h" -#include "combustion/htrdr_combustion.h" +#ifdef HTRDR_BUILD_ATMOSPHERE + #include "atmosphere/htrdr_atmosphere.h" +#endif +#ifdef HTRDR_BUILD_COMBUSTION + #include "combustion/htrdr_combustion.h" +#endif + +#include "core/htrdr_log.h" #include "core/htrdr_version.h" +#include <rsys/rsys.h> #include <string.h> /******************************************************************************* @@ -45,7 +52,7 @@ print_help(const char* cmd) " --help display this help and exit.\n"); printf("\n"); - printf("These are %s available modes:\n", cmd); + printf("These are %s modes:\n", cmd); printf("\n"); printf( " atmosphere Radiative transfer computations in a cloudy atmosphere.\n"); @@ -72,14 +79,28 @@ main(int argc, char** argv) } /* Atmosphere mode */ - if(!strcmp(argv[1], "atmosphere")) { + if(!strcmp(argv[1], "atmosphere")) { +#ifdef HTRDR_BUILD_ATMOSPHERE err = htrdr_atmosphere_main(argc-1, argv+1); if(err) goto error; +#else + fprintf(stderr, + "The atmosphere mode is not available in this htrdr build.\n"); + err = 1; + goto error; +#endif /* Combustion mode */ - } else if(!strcmp(argv[1], "combustion")) { + } else if(!strcmp(argv[1], "combustion")) { +#ifdef HTRDR_BUILD_COMBUSTION err = htrdr_combustion_main(argc-1, argv+1); if(err) goto error; +#else + fprintf(stderr, + "The combustion mode is not available in this htrdr build.\n"); + err = 1; + goto error; +#endif /* Version */ } else if(!strcmp(argv[1], "--version")) { diff --git a/src/commands/htrdr_combustion_cmd.c b/src/commands/htrdr_combustion_cmd.c @@ -15,10 +15,21 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "combustion/htrdr_combustion.h" +#ifdef HTRDR_BUILD_COMBUSTION + #include "combustion/htrdr_combustion.h" +#else + #include <stdio.h> +#endif int main(int argc, char** argv) { +#ifdef HTRDR_BUILD_COMBUSTION return htrdr_combustion_main(argc, argv); +#else + (void)argc, (void)argv; + fprintf(stderr, + "The htrdr-combustion command is not available in this htrdr build.\n"); + return 1; +#endif }