diff options
author | Allen Byrne <50328838+byrnHDF@users.noreply.github.com> | 2022-01-14 04:18:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-14 04:18:36 (GMT) |
commit | 1c8d7a2dc01ff61a7949f3da58afde3c59f2729b (patch) | |
tree | 8aff2b39fbbe73dfada55e3a5c4c3fb49da4166d /src | |
parent | a0c2b2e8d430b8622cb6e0ff67b3b0317dd8fe48 (diff) | |
download | hdf5-1c8d7a2dc01ff61a7949f3da58afde3c59f2729b.zip hdf5-1c8d7a2dc01ff61a7949f3da58afde3c59f2729b.tar.gz hdf5-1c8d7a2dc01ff61a7949f3da58afde3c59f2729b.tar.bz2 |
Merge cmake custom command changes (#1360)
Diffstat (limited to 'src')
-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 a81c4bb..e08f485 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1034,20 +1034,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 @@ -1055,9 +1058,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} @@ -1068,31 +1071,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 () @@ -1108,16 +1110,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 () @@ -1128,6 +1129,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}) @@ -1147,10 +1149,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 @@ -1159,17 +1163,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" @@ -1182,7 +1186,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" ) @@ -1221,7 +1225,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" ) |