diff options
-rw-r--r-- | src/CMakeLists.txt | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ed5f67..da99dc6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1056,20 +1056,23 @@ if (LOCAL_BATCH_TEST) endif () endif () +#### make the H5detect program set (lib_prog_deps) -if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") - add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) - target_include_directories (H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) - TARGET_C_PROPERTIES (H5detect STATIC) - target_link_libraries (H5detect - PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib> - ) - target_compile_options(H5detect - PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>" - ) - set (lib_prog_deps ${lib_prog_deps} H5detect) +add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) +target_include_directories (H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) +TARGET_C_PROPERTIES (H5detect STATIC) +target_link_libraries (H5detect + PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib> +) +target_compile_options(H5detect + PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>" +) +set (lib_prog_deps ${lib_prog_deps} H5detect) +# check if a pregenerated H5Tinit.c file is present +if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") + # execute the H5detect program if (HDF5_BATCH_H5DETECT) configure_file ( ${HDF5_SOURCE_DIR}/bin/batch/${HDF5_BATCH_H5DETECT_SCRIPT}.in.cmake @@ -1077,9 +1080,9 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") ) add_custom_command ( OUTPUT gen_SRCS.stamp1 + BYPRODUCTS H5Tinit.c COMMAND ${HDF5_BATCH_CMD} ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} - BYPRODUCTS H5Tinit.c gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E echo "Executed batch command to create H5Tinit.c" COMMAND ${CMAKE_COMMAND} @@ -1090,31 +1093,30 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c") add_custom_target (gen_H5Tinit COMMAND ${CMAKE_COMMAND} -P ${HDF5_SOURCE_DIR}/config/cmake/wait_H5Tinit.cmake ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) else () - add_custom_command (TARGET H5detect POST_BUILD + add_custom_command ( + OUTPUT gen_SRCS.stamp1 + BYPRODUCTS H5Tinit.c COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5detect> ARGS H5Tinit.c - BYPRODUCTS H5Tinit.c gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch gen_SRCS.stamp1 DEPENDS H5detect WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Create H5Tinit.c" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) - add_custom_command (TARGET H5detect POST_BUILD + add_custom_command ( + OUTPUT shared/shared_gen_SRCS.stamp1 + BYPRODUCTS shared/H5Tinit.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c - BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp1 - DEPENDS H5detect H5Tinit.c + DEPENDS H5detect gen_SRCS.stamp1 WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Copy H5Tinit.c to shared folder" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () endif () else () @@ -1130,16 +1132,15 @@ else () if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT shared/shared_gen_SRCS.stamp1 + BYPRODUCTS shared/H5Tinit.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c - BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp1 - DEPENDS H5Tinit.c + DEPENDS H5Tinit.c gen_SRCS.stamp1 WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} COMMENT "Copy existing H5Tinit.c to shared folder" ) - set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () endif () @@ -1150,6 +1151,7 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_SRC_DETECT_FORMAT ${HDF5_SRC_DIR}/H5detect.c) endif () +# make the H5make_libsettings program add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c) target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) @@ -1169,10 +1171,12 @@ if (HDF5_ENABLE_FORMATTERS) clang_format (HDF5_SRC_LIBSETTINGS_FORMAT H5make_libsettings) endif () -add_custom_command (TARGET H5make_libsettings POST_BUILD +# execute the H5make_libsettings program +add_custom_command ( + OUTPUT gen_SRCS.stamp2 + BYPRODUCTS H5lib_settings.c COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5make_libsettings> ARGS H5lib_settings.c - BYPRODUCTS H5lib_settings.c gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E touch gen_SRCS.stamp2 DEPENDS H5make_libsettings @@ -1181,17 +1185,17 @@ add_custom_command (TARGET H5make_libsettings POST_BUILD ) set_source_files_properties (${HDF5_SRC_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE) if (BUILD_SHARED_LIBS) - add_custom_command (TARGET H5make_libsettings POST_BUILD + add_custom_command ( + OUTPUT shared/shared_gen_SRCS.stamp2 + BYPRODUCTS shared/H5lib_settings.c COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different H5lib_settings.c shared/H5lib_settings.c - BYPRODUCTS shared/H5lib_settings.c shared/shared_gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E touch shared/shared_gen_SRCS.stamp2 - DEPENDS H5make_libsettings H5lib_settings.c + DEPENDS H5make_libsettings gen_SRCS.stamp2 WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR} COMMENT "Copy H5lib_settings.c to shared folder" ) - set_source_files_properties (${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE) endif () ## all_packages="AC,B,B2,D,F,FA,FL,FS,HL,I,O,S,ST,T,Z" @@ -1204,7 +1208,7 @@ option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF) if (NOT ONLY_SHARED_LIBS) set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c) add_custom_target (gen_${HDF5_LIB_TARGET} ALL - DEPENDS ${lib_prog_deps} ${gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2 + DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2 COMMENT "Generation target files" ) @@ -1243,7 +1247,7 @@ endif () if (BUILD_SHARED_LIBS) set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c) add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL - DEPENDS ${lib_prog_deps} ${shared_gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 + DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 COMMENT "Shared generation target files" ) |