Skip to content

Commit 47a5215

Browse files
committed
shared lib options
1 parent afed4a3 commit 47a5215

7 files changed

Lines changed: 20 additions & 69 deletions

File tree

.archive/netcdf.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ DEPENDS HDF5::HDF5
6363
file(MAKE_DIRECTORY ${NetCDF_C_INCLUDE_DIRS})
6464
# avoid race condition
6565

66-
# this GLOBAL is required to be visible via other project's FetchContent
67-
add_library(NetCDF::NetCDF_C INTERFACE IMPORTED GLOBAL)
66+
add_library(NetCDF::NetCDF_C INTERFACE IMPORTED)
6867
target_include_directories(NetCDF::NetCDF_C INTERFACE ${NetCDF_C_INCLUDE_DIRS})
6968
target_link_libraries(NetCDF::NetCDF_C INTERFACE ${NetCDF_C_LIBRARIES})
7069

@@ -75,7 +74,7 @@ target_link_libraries(NetCDF::NetCDF_C INTERFACE HDF5::HDF5)
7574

7675
# --- NetCDF-Fortran
7776

78-
cmake_path(SET NetCDF_Fortran_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
77+
cmake_path(SET NetCDF_Fortran_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR})
7978

8079
set(netcdf_fortran_cmake_args
8180
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
@@ -109,8 +108,7 @@ DEPENDS NETCDF_C
109108

110109
# --- imported target
111110

112-
# this GLOBAL is required to be visible via other project's FetchContent
113-
add_library(NetCDF::NetCDF_Fortran INTERFACE IMPORTED GLOBAL)
111+
add_library(NetCDF::NetCDF_Fortran INTERFACE IMPORTED)
114112
target_include_directories(NetCDF::NetCDF_Fortran INTERFACE ${NetCDF_Fortran_INCLUDE_DIRS})
115113
target_link_libraries(NetCDF::NetCDF_Fortran INTERFACE ${NetCDF_Fortran_LIBRARIES} NetCDF::NetCDF_C)
116114

cmake/hdf5.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ USES_TERMINAL_TEST true
103103
file(MAKE_DIRECTORY ${HDF5_INCLUDE_DIRS})
104104
# avoid race condition
105105

106-
# this GLOBAL is required to be visible to parent projects
107-
add_library(HDF5::HDF5 INTERFACE IMPORTED GLOBAL)
106+
add_library(HDF5::HDF5 INTERFACE IMPORTED)
108107
target_include_directories(HDF5::HDF5 INTERFACE "${HDF5_INCLUDE_DIRS}")
109108
target_link_libraries(HDF5::HDF5 INTERFACE "${HDF5_LIBRARIES}")
110109

cmake/nc4fortran.cmake

Lines changed: 0 additions & 41 deletions
This file was deleted.

cmake/netcdf-c.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(NetCDF_C_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
1+
set(NetCDF_C_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR})
22

33
set(netcdf_c_cmake_args
44
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
@@ -55,8 +55,7 @@ USES_TERMINAL_TEST true
5555
file(MAKE_DIRECTORY ${NetCDF_C_INCLUDE_DIRS})
5656
# avoid race condition
5757

58-
# this GLOBAL is required to be visible via other project's FetchContent
59-
add_library(NetCDF::NetCDF_C INTERFACE IMPORTED GLOBAL)
58+
add_library(NetCDF::NetCDF_C INTERFACE IMPORTED)
6059
target_include_directories(NetCDF::NetCDF_C INTERFACE "${NetCDF_C_INCLUDE_DIRS}")
6160
target_link_libraries(NetCDF::NetCDF_C INTERFACE "${NetCDF_C_LIBRARIES}")
6261

cmake/netcdf.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ USES_TERMINAL_TEST true
8181
file(MAKE_DIRECTORY ${NetCDF_Fortran_INCLUDE_DIRS})
8282
# avoid race condition
8383

84-
# this GLOBAL is required to be visible via other project's FetchContent
85-
add_library(NetCDF::NetCDF_Fortran INTERFACE IMPORTED GLOBAL)
84+
add_library(NetCDF::NetCDF_Fortran INTERFACE IMPORTED)
8685
target_include_directories(NetCDF::NetCDF_Fortran INTERFACE "${NetCDF_Fortran_INCLUDE_DIRS}")
8786
target_link_libraries(NetCDF::NetCDF_Fortran INTERFACE "${NetCDF_Fortran_LIBRARIES}")
8887

cmake/zlib.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ USES_TERMINAL_TEST true
5353
file(MAKE_DIRECTORY ${ZLIB_INCLUDE_DIRS})
5454
# avoid race condition
5555

56-
# for visibility in parent projects
57-
add_library(ZLIB::ZLIB INTERFACE IMPORTED GLOBAL)
56+
add_library(ZLIB::ZLIB INTERFACE IMPORTED)
5857
add_dependencies(ZLIB::ZLIB ZLIB) # to avoid include directory race condition
5958
target_link_libraries(ZLIB::ZLIB INTERFACE ${ZLIB_LIBRARIES})
6059
target_include_directories(ZLIB::ZLIB INTERFACE ${ZLIB_INCLUDE_DIRS})

test/CMakeLists.txt

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@ EXECUTABLE ${CMAKE_CTEST_COMMAND}
4343
endif()
4444

4545
# --- NetCDF shared lib paths needed
46-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
47-
if(WIN32)
48-
set_property(TEST minimal ${test_names} PROPERTY
49-
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:${NetCDF_Fortran_INCLUDE_DIRS}/../bin"
50-
)
51-
elseif(APPLE)
52-
set_property(TEST minimal ${test_names} PROPERTY
53-
ENVIRONMENT_MODIFICATION "DYLD_LIBRARY_PATH=path_list_prepend:${NetCDF_Fortran_INCLUDE_DIRS}/../lib"
54-
)
55-
else()
56-
set_property(TEST minimal ${test_names} PROPERTY
57-
ENVIRONMENT_MODIFICATION "LD_LIBRARY_PATH=path_list_prepend:${NetCDF_Fortran_INCLUDE_DIRS}/../lib"
58-
)
59-
endif()
46+
if(WIN32)
47+
set_property(TEST minimal ${test_names} PROPERTY
48+
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:${NetCDF_Fortran_INCLUDE_DIRS}/../bin"
49+
)
50+
elseif(APPLE)
51+
set_property(TEST minimal ${test_names} PROPERTY
52+
ENVIRONMENT_MODIFICATION "DYLD_LIBRARY_PATH=path_list_prepend:${NetCDF_Fortran_INCLUDE_DIRS}/../lib"
53+
)
54+
else()
55+
set_property(TEST minimal ${test_names} PROPERTY
56+
ENVIRONMENT_MODIFICATION "LD_LIBRARY_PATH=path_list_prepend:${NetCDF_Fortran_INCLUDE_DIRS}/../lib"
57+
)
6058
endif()

0 commit comments

Comments
 (0)