Skip to content

Commit

Permalink
[CMake] always use target_include_directories
Browse files Browse the repository at this point in the history
We had some remaining "global" include_directories. Using
target_include_directories means it's more specific, and we don't need
to explicitly export them anymore.

This reduces possible conflicts when importing STIR.
  • Loading branch information
KrisThielemans committed Sep 30, 2024
1 parent 6417022 commit 7c24e41
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ option(BUILD_SHARED_LIBS
if (LLN_FOUND)
set(HAVE_ECAT ON)
message(STATUS "ECAT support enabled.")
include_directories(${LLN_INCLUDE_DIRS})
else()
message(STATUS "ECAT support disabled.")
endif()
Expand All @@ -52,7 +51,6 @@ endif()
if ((NOT DISABLE_HDF5) AND HDF5_FOUND)
set(HAVE_HDF5 ON)
message(STATUS "HDF5 support enabled.")
include_directories(${HDF5_INCLUDE_DIRS})
else()
message(STATUS "HDF5 support disabled.")
endif()
Expand Down Expand Up @@ -120,7 +118,6 @@ endif()

if (STIR_MPI)
find_package(MPI REQUIRED)
include_directories(${MPI_CXX_INCLUDE_PATH})
# we add MPI_CXX_COMPILE_FLAGS for all files
add_definitions(${MPI_CXX_COMPILE_FLAGS} -DMPICH_IGNORE_CXX_SEEK)
# However, currently we decide to add MPI_CXX_LINK_FLAGS only to those programs that need it,
Expand Down
2 changes: 2 additions & 0 deletions src/IO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ endif()
include(stir_lib_target)

if (LLN_FOUND)
target_include_directories(IO PUBLIC ${LLN_INCLUDE_DIRS})
target_link_libraries(IO PUBLIC ${LLN_LIBRARIES})
endif()

Expand All @@ -90,6 +91,7 @@ if (CERN_ROOT_FOUND)
endif()

if (HAVE_HDF5)
target_include_directories(IO PUBLIC ${HDF5_INCLUDE_DIRS})
target_link_libraries(IO PUBLIC ${HDF5_CXX_LIBRARIES})
endif()

Expand Down
4 changes: 0 additions & 4 deletions src/cmake/STIRConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,13 @@ if (@HDF5_FOUND@)
find_package(HDF5 @HDF5_VERSION@ QUIET COMPONENTS C CXX)
endif()
find_package(HDF5 @HDF5_VERSION@ REQUIRED COMPONENTS CXX )
include_directories(${HDF5_INCLUDE_DIRS})

set(STIR_BUILT_WITH_HDF5 TRUE)
endif()

if (@LLN_FOUND@)
set(HAVE_ECAT ON)
message(STATUS "ECAT support in STIR enabled.")
# need to add this as stir_ecat7.h etc rely on it
# would be better to add it to STIR_INCLUDE_DIRS (TODO)
include_directories("@LLN_INCLUDE_DIRS@")
set(STIR_BUILT_WITH_LLN_MATRIX TRUE)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/display/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ include(stir_lib_target)

if( "${GRAPHICS}" STREQUAL "X")
find_package(Curses REQUIRED)
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR} ${CURSES_INCLUDE_DIR})
target_include_directories(${dir} ${X11_INCLUDE_DIR} ${CURSES_INCLUDE_DIR})
target_link_libraries(${dir} PUBLIC ${X11_LIBRARIES} ${CURSES_LIBRARY})
endif()

Expand Down
3 changes: 2 additions & 1 deletion src/recon_buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ endif()
include(stir_lib_target)

if (STIR_MPI)
target_include_directories(recon_buildblock ${MPI_CXX_INCLUDE_PATH})
target_link_libraries(recon_buildblock PUBLIC ${MPI_CXX_LIBRARIES})
endif()

Expand Down Expand Up @@ -162,4 +163,4 @@ endif()

if (STIR_WITH_CUDA)
target_link_libraries(recon_buildblock PUBLIC CUDA::cudart)
endif()
endif()
2 changes: 1 addition & 1 deletion src/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ if (BUILD_SWIG_MATLAB)

SWIG_LINK_LIBRARIES(stirMATLAB PUBLIC ${STIR_LIBRARIES} ${Matlab_LIBRARIES})

include_directories(${Matlab_INCLUDE_DIRS})
target_include_directories(${SWIG_MODULE_stirMATLAB_REAL_NAME} PUBLIC ${Matlab_INCLUDE_DIRS})
# disabled, as currently set via add_definitions in main CMakeLists.txt
#SET_SOURCE_FILES_PROPERTIES( ${swig_generated_file_fullname}
# PROPERTIES COMPILE_FLAGS "${MATLAB_CXXFLAGS}")
Expand Down

0 comments on commit 7c24e41

Please sign in to comment.