From 1f11e0f2c028e8f095396bd319fc7f1b51a0ad9d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 1 Dec 2023 10:15:57 -0600 Subject: [PATCH] Fix sequence and variable usage --- C/H5FLT/CMakeLists.txt | 8 +++ CMakeLists.txt | 72 ++++++++++++++++++-------- FORTRAN/H5D/CMakeLists.txt | 6 +-- FORTRAN/H5G/CMakeLists.txt | 6 +-- FORTRAN/H5PAR/CMakeLists.txt | 4 +- FORTRAN/H5T/CMakeLists.txt | 13 ++++- JAVA/H5D/CMakeLists.txt | 6 +-- config/cmake/HDFExampleMacros.cmake | 47 +++++------------ config/cmake/HDFMacros.cmake | 78 ++++++++++++++++++----------- 9 files changed, 142 insertions(+), 98 deletions(-) diff --git a/C/H5FLT/CMakeLists.txt b/C/H5FLT/CMakeLists.txt index eb386b4..68189e6 100644 --- a/C/H5FLT/CMakeLists.txt +++ b/C/H5FLT/CMakeLists.txt @@ -190,6 +190,8 @@ if (H5EX_BUILD_TESTING) -D "TEST_MASK_ERROR=true" -D "TEST_OUTPUT=${testname}.out" -D "TEST_REFERENCE=${testname}.tst" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}" -D "TEST_SKIP_COMPARE=1" -D "TEST_ERRREF=1" -D "GREP_ERRREF=Filter present but encoding disabled" @@ -214,6 +216,8 @@ if (H5EX_BUILD_TESTING) -D "TEST_EXPECT=0" -D "TEST_OUTPUT=${testname}.out" -D "TEST_REFERENCE=${testname}.tst" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}" -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_LIB_DIRECTORY}" -P "${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/runTest.cmake" ) @@ -233,6 +237,8 @@ if (H5EX_BUILD_TESTING) -D "TEST_FILTER_REPLACE=PARAMS { \\1 XXXX \\2 }\n" -D "TEST_EXPECT=0" -D "TEST_REFERENCE=${testname}.ddl" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}" -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_LIB_DIRECTORY}" -P "${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/runTest.cmake" ) @@ -248,6 +254,8 @@ if (H5EX_BUILD_TESTING) -D "TEST_FILTER_REPLACE:STRING=PARAMS { XXXX }" -D "TEST_EXPECT=0" -D "TEST_REFERENCE=${testname}.ddl" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}" -D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_LIB_DIRECTORY}" -P "${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/runTest.cmake" ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a6eb4e..69f1df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,25 @@ cmake_minimum_required (VERSION 3.12) project (H5EXAMPLES C CXX) +#----------------------------------------------------------------------------- +# Define some CMake variables for use later in the project +#----------------------------------------------------------------------------- +set (HDF5EX_C_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/C) +set (HDF5EX_F90_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/FORTRAN) +set (HDF5EX_JAVA_DIR ${H5EXAMPLES_SOURCE_DIR}/JAVA) +set (HDF5EX_RESOURCES_DIR ${H5EXAMPLES_SOURCE_DIR}/config/cmake) + #----------------------------------------------------------------------------- # Basic HDF5Examples stuff here #----------------------------------------------------------------------------- -include (${H5EXAMPLES_SOURCE_DIR}/config/cmake/HDFMacros.cmake) -include (${H5EXAMPLES_SOURCE_DIR}/config/cmake/HDFExampleMacros.cmake) +include (${HDF5EX_RESOURCES_DIR}/HDFMacros.cmake) +include (${HDF5EX_RESOURCES_DIR}/HDFExampleMacros.cmake) set (CMAKE_JAVA_INCLUDE_PATH "") SET_HDF_BUILD_TYPE() BASIC_SETTINGS (EXAMPLES) -#----------------------------------------------------------------------------- -# Define some CMake variables for use later in the project -#----------------------------------------------------------------------------- -set (HDF5EX_C_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/C) -set (HDF5EX_F90_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/FORTRAN) -set (HDF5EX_JAVA_DIR ${H5EXAMPLES_SOURCE_DIR}/JAVA) - #----------------------------------------------------------------------------- # HDF5 support #----------------------------------------------------------------------------- @@ -119,11 +120,6 @@ if (H5EX_BUILD_TESTING) configure_file (${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/CTestCustom.cmake ${PROJECT_BINARY_DIR}/CTestCustom.ctest @ONLY) endif () -#----------------------------------------------------------------------------- -# Build examples -#----------------------------------------------------------------------------- -add_subdirectory (C) - if (${H5_LIBVER_DIR} GREATER 16) #----------------------------------------------------------------------------- # Option to build Fortran examples @@ -136,19 +132,22 @@ if (${H5_LIBVER_DIR} GREATER 16) if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/FORTRAN" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/FORTRAN") option (HDF_BUILD_FORTRAN "Build FORTRAN support" OFF) if (HDF_BUILD_FORTRAN AND HDF5_BUILD_FORTRAN) - set (LINK_Fortran_LIBS ${H5EX_HDF5_LINK_LIBS}) + set (H5EX_LINK_Fortran_LIBS ${H5EX_HDF5_LINK_LIBS}) # Parallel IO usage requires MPI to be Linked and Included if (H5_HAVE_PARALLEL) - set (LINK_Fortran_LIBS ${LINK_Fortran_LIBS} ${MPI_Fortran_LIBRARIES}) + set (H5EX_LINK_Fortran_LIBS ${H5EX_LINK_Fortran_LIBS} ${MPI_Fortran_LIBRARIES}) if (MPI_Fortran_LINK_FLAGS) set (CMAKE_Fortran_EXE_LINKER_FLAGS "${MPI_Fortran_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") endif () endif () - add_subdirectory (FORTRAN) configure_file (${HDF5EX_F90_SRC_DIR}/H5D/h5_version.h.in ${PROJECT_BINARY_DIR}/FORTRAN/H5D/h5_version.h @ONLY) + else () + set (HDF_BUILD_FORTRAN OFF CACHE BOOL "Build examples FORTRAN support" FORCE) endif () + else () + set (HDF_BUILD_FORTRAN OFF CACHE BOOL "Build examples FORTRAN support" FORCE) endif () if (${H5_LIBVER_DIR} GREATER 18) @@ -157,16 +156,47 @@ if (${H5_LIBVER_DIR} GREATER 16) #----------------------------------------------------------------------------- if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/JAVA" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/JAVA") option (HDF_BUILD_JAVA "Build JAVA support" OFF) - if (HDF_BUILD_JAVA AND HDF5_BUILD_JAVA) - add_subdirectory (JAVA) - endif () + else () + set (HDF_BUILD_JAVA OFF CACHE BOOL "Build examples JAVA support" FORCE) endif () + else () + set (HDF_BUILD_JAVA OFF CACHE BOOL "Build examples JAVA support" FORCE) endif () #----------------------------------------------------------------------------- # Option to build filter examples #----------------------------------------------------------------------------- - if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/C/H5F" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/C/H5F") + if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/C/H5FLT" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/C/H5FLT") option (HDF_BUILD_FILTERS "Test filter support" OFF) + if (HDF_BUILD_FILTERS AND HDF5_ENABLE_PLUGIN_SUPPORT) + if(DEFINED ENV{HDF5_PLUGIN_PATH}) + message (STATUS "ENV PATH=$ENV{HDF5_PLUGIN_PATH}") + set (H5EX_HDF5_PLUGIN_PATH $ENV{HDF5_PLUGIN_PATH}) + else () + message (STATUS "LIBRARY PATH=${HDF5_LIBRARY_PATH}/plugin") + set (H5EX_HDF5_PLUGIN_PATH ${HDF5_LIBRARY_PATH}/plugin) + endif () + message (STATUS "H5EX_HDF5_PLUGIN_PATH=${H5EX_HDF5_PLUGIN_PATH}") + else () + set (HDF_BUILD_FILTERS OFF CACHE BOOL "Build examples PLUGIN filter support" FORCE) + endif () + else () + set (HDF_BUILD_FILTERS OFF CACHE BOOL "Build examples PLUGIN filter support" FORCE) endif () +else () + set (HDF_BUILD_FORTRAN OFF} CACHE BOOL "Build examples FORTRAN support" FORCE) + set (HDF_BUILD_JAVA OFF CACHE BOOL "Build examples JAVA support" FORCE) + set (HDF_BUILD_FILTERS OFF CACHE BOOL "Build examples PLUGIN filter support" FORCE) endif () + +#----------------------------------------------------------------------------- +# Build examples +#----------------------------------------------------------------------------- +add_subdirectory (C) +if (HDF_BUILD_FORTRAN AND HDF5_BUILD_FORTRAN) + add_subdirectory (FORTRAN) +endif () +if (HDF_BUILD_JAVA AND HDF5_BUILD_JAVA) + add_subdirectory (JAVA) +endif () + diff --git a/FORTRAN/H5D/CMakeLists.txt b/FORTRAN/H5D/CMakeLists.txt index dbc126c..98b9d63 100644 --- a/FORTRAN/H5D/CMakeLists.txt +++ b/FORTRAN/H5D/CMakeLists.txt @@ -10,7 +10,7 @@ project (HDF5Examples_FORTRAN_H5D C CXX Fortran) # Setup include Directories #----------------------------------------------------------------------------- INCLUDE_DIRECTORIES ( - ${CMAKE_Fortran_MODULE_DIRECTORY} + ${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT} ${PROJECT_BINARY_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ) @@ -35,7 +35,7 @@ foreach (example_name ${common_examples}) if (H5_HAVE_PARALLEL) target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () - target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS}) + target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS}) set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran) if (H5EX_BUILD_TESTING) if (${example_name} STREQUAL "h5ex_d_alloc") @@ -80,7 +80,7 @@ if (HDF5_VERSION_MAJOR VERSION_GREATER_EQUAL "1.10") if (H5_HAVE_PARALLEL) target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_C_INCLUDE_DIRS}) endif () - target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_HDF5_LINK_LIBS}) + target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS}) if (H5EX_BUILD_TESTING) add_custom_command ( TARGET ${EXAMPLE_VARNAME}_f90_${example_name} diff --git a/FORTRAN/H5G/CMakeLists.txt b/FORTRAN/H5G/CMakeLists.txt index d2587e0..7a19bf4 100644 --- a/FORTRAN/H5G/CMakeLists.txt +++ b/FORTRAN/H5G/CMakeLists.txt @@ -10,7 +10,7 @@ project (HDF5Examples_FORTRAN_H5G C CXX Fortran) # Setup include Directories #----------------------------------------------------------------------------- INCLUDE_DIRECTORIES ( - ${CMAKE_Fortran_MODULE_DIRECTORY} + ${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT} ${PROJECT_BINARY_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ) @@ -35,7 +35,7 @@ foreach (example_name ${common_examples}) if (H5_HAVE_PARALLEL) target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () - target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS}) + target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS}) set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran) if (H5EX_BUILD_TESTING) if (NOT ${example_name} STREQUAL "h5ex_g_create" AND NOT ${example_name} STREQUAL "h5ex_g_compact") @@ -64,7 +64,7 @@ endforeach () # if (H5_HAVE_PARALLEL) # target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_C_INCLUDE_DIRS}) # endif () -# target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_HDF5_LINK_LIBS}) +# target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS}) # if (H5EX_BUILD_TESTING) # add_custom_command ( # TARGET ${EXAMPLE_VARNAME}_f90_${example_name} diff --git a/FORTRAN/H5PAR/CMakeLists.txt b/FORTRAN/H5PAR/CMakeLists.txt index 84c9641..4a93bca 100644 --- a/FORTRAN/H5PAR/CMakeLists.txt +++ b/FORTRAN/H5PAR/CMakeLists.txt @@ -10,7 +10,7 @@ project (HDF5Examples_FORTRAN_H5PAR C CXX Fortran) # Setup include Directories #----------------------------------------------------------------------------- INCLUDE_DIRECTORIES ( - ${CMAKE_Fortran_MODULE_DIRECTORY} + ${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT} ${PROJECT_BINARY_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ) @@ -33,7 +33,7 @@ foreach (example_name ${examples}) "$<$:-DH5_USE_116_API>" ) target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) - target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS}) + target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS}) set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran) endforeach () diff --git a/FORTRAN/H5T/CMakeLists.txt b/FORTRAN/H5T/CMakeLists.txt index 67a3ca3..9b4a513 100644 --- a/FORTRAN/H5T/CMakeLists.txt +++ b/FORTRAN/H5T/CMakeLists.txt @@ -1,6 +1,15 @@ cmake_minimum_required (VERSION 3.12) project (HDF5Examples_FORTRAN_H5T C CXX Fortran) +#----------------------------------------------------------------------------- +# Setup include Directories +#----------------------------------------------------------------------------- +INCLUDE_DIRECTORIES ( + ${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT} + ${PROJECT_BINARY_DIR} + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} +) + #----------------------------------------------------------------------------- # Define Sources #----------------------------------------------------------------------------- @@ -21,7 +30,7 @@ include (Fortran_sourcefiles.cmake) if (H5_HAVE_PARALLEL) target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () - target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS}) + target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS}) set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran) if (H5EX_BUILD_TESTING) add_custom_command ( @@ -48,7 +57,7 @@ foreach (example_name ${common_examples}) if (H5_HAVE_PARALLEL) target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () - target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS}) + target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS}) set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran) if (H5EX_BUILD_TESTING) add_custom_command ( diff --git a/JAVA/H5D/CMakeLists.txt b/JAVA/H5D/CMakeLists.txt index 60c35dc..c099459 100644 --- a/JAVA/H5D/CMakeLists.txt +++ b/JAVA/H5D/CMakeLists.txt @@ -32,12 +32,12 @@ endforeach () foreach (example ${HDF_JAVA_EXAMPLES}) get_filename_component (example_name ${example} NAME_WE) - file (WRITE ${PROJECT_BINARY_DIR}/Manifest.txt + file (WRITE ${PROJECT_BINARY_DIR}/${example_name}_Manifest.txt "Main-Class: ${example_name} Class-Path: ${HDFJAVA_CLASSJARS} " ) - add_jar (${EXAMPLE_VARNAME}_${example_name} SOURCES ${example} MANIFEST ${PROJECT_BINARY_DIR}/Manifest.txt) + add_jar (${EXAMPLE_VARNAME}_${example_name} SOURCES ${example} MANIFEST ${PROJECT_BINARY_DIR}/${example_name}_Manifest.txt) get_target_property (${EXAMPLE_VARNAME}_${example_name}_JAR_FILE ${EXAMPLE_VARNAME}_${example_name} JAR_FILE) endforeach () @@ -46,7 +46,7 @@ if (H5EX_BUILD_TESTING) add_test ( NAME ${EXAMPLE_VARNAME}_jnative-h5-${resultfile} COMMAND "${CMAKE_COMMAND}" - -D "TEST_TESTER=${CMAKE_Java_RUNTIME}" + -D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}" -D "TEST_PROGRAM=${resultfile}" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${EXAMPLE_VARNAME}_${resultfile}_JAR_FILE}" diff --git a/config/cmake/HDFExampleMacros.cmake b/config/cmake/HDFExampleMacros.cmake index d9bf67f..fa1e0fc 100644 --- a/config/cmake/HDFExampleMacros.cmake +++ b/config/cmake/HDFExampleMacros.cmake @@ -1,3 +1,15 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + #------------------------------------------------------------------------------- macro (BASIC_SETTINGS varname) string (TOUPPER ${varname} EXAMPLE_PACKAGE_VARNAME) @@ -17,35 +29,7 @@ macro (BASIC_SETTINGS varname) #----------------------------------------------------------------------------- # Setup output Directories #----------------------------------------------------------------------------- - if (NOT ${EXAMPLE_PACKAGE_NAME}_EXTERNALLY_CONFIGURED) - set (CMAKE_RUNTIME_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables." - ) - set (CMAKE_LIBRARY_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries" - ) - set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries." - ) - set (CMAKE_Fortran_MODULE_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all fortran modules." - ) - get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(_isMultiConfig) - set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}) - set (CMAKE_PDB_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all pdb files." - ) - else () - set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - endif () - else () - # if we are externally configured, but the project uses old cmake scripts - # this may not be set - if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - endif () - endif () + SET_HDF_OUTPUT_DIRS(${EXAMPLE_PACKAGE_NAME}) #----------------------------------------------------------------------------- # Option to use Shared/Static libs, default is static @@ -285,11 +269,6 @@ macro (HDF5_SUPPORT) else () set (H5_LIB_TYPE STATIC) endif () - - #----------------------------------------------------------------------------- - # Option to build filter examples - #----------------------------------------------------------------------------- - option (HDF_BUILD_FILTERS "Test filter support" OFF) endmacro () #------------------------------------------------------------------------------- diff --git a/config/cmake/HDFMacros.cmake b/config/cmake/HDFMacros.cmake index 9ce592d..3459531 100644 --- a/config/cmake/HDFMacros.cmake +++ b/config/cmake/HDFMacros.cmake @@ -1,3 +1,50 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://www.hdfgroup.org/licenses. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +#------------------------------------------------------------------------------- +# Setup output Directories +#----------------------------------------------------------------------------- +macro (SET_HDF_OUTPUT_DIRS package_prefix) + if (NOT ${package_prefix}_EXTERNALLY_CONFIGURED) + set (CMAKE_RUNTIME_OUTPUT_DIRECTORY + ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables." + ) + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY + ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries" + ) + set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY + ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries." + ) + set (CMAKE_Fortran_MODULE_DIRECTORY + ${PROJECT_BINARY_DIR}/mod CACHE PATH "Single Directory for all fortran modules." + ) + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(_isMultiConfig) + set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${HDF_CFG_NAME}) + set (CMAKE_PDB_OUTPUT_DIRECTORY + ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all pdb files." + ) + else () + set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + endif () + else () + # if we are externally configured, but the project uses old cmake scripts + # this may not be set and utilities like H5detect will fail + if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) + endif () + endif () +endmacro () + #------------------------------------------------------------------------------- macro (SET_HDF_BUILD_TYPE) get_property (_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) @@ -156,39 +203,10 @@ macro (HDF_DIR_PATHS package_prefix) endif () SET_HDF_BUILD_TYPE() - #----------------------------------------------------------------------------- # Setup output Directories #----------------------------------------------------------------------------- - if (NOT ${package_prefix}_EXTERNALLY_CONFIGURED) - set (CMAKE_RUNTIME_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables." - ) - set (CMAKE_LIBRARY_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries" - ) - set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries." - ) - set (CMAKE_Fortran_MODULE_DIRECTORY - ${PROJECT_BINARY_DIR}/mod CACHE PATH "Single Directory for all fortran modules." - ) - get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(_isMultiConfig) - set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${HDF_CFG_NAME}) - set (CMAKE_PDB_OUTPUT_DIRECTORY - ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all pdb files." - ) - else () - set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - endif () - else () - # if we are externally configured, but the project uses old cmake scripts - # this may not be set and utilities like H5detect will fail - if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) - set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) - endif () - endif () + SET_HDF_OUTPUT_DIRS(${package_prefix}) include (FetchContent) endmacro ()