Skip to content

Commit

Permalink
Merge pull request #1518 from KrisThielemans/CMake_restrict_includes
Browse files Browse the repository at this point in the history
restrict includes for CMake
  • Loading branch information
KrisThielemans authored Feb 6, 2025
2 parents 2f521c3 + e88bbf5 commit ac0d0b3
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 14 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
6 changes: 3 additions & 3 deletions src/buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ if (LLN_FOUND)
target_link_libraries(buildblock PUBLIC ${LLN_LIBRARIES})
endif()

if (RDF_FOUND)
# TODO cannot do this as it creates circular dependencies
# target_link_libraries(buildblock PUBLIC local_IO_GE)
if (HAVE_HDF5)
# for GEHDF5, TODO remove once IO dependency added or GEHDF5Wrapper no longer includes H5Cpp.h
target_include_directories(buildblock PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

# TODO currently needed as filters need fourier
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 @@ -102,17 +102,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
5 changes: 5 additions & 0 deletions src/data_buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ endif()
include(stir_lib_target)

target_link_libraries(${dir} PUBLIC buildblock)

if (HAVE_HDF5)
# for GEHDF5, TODO remove once IO dependency added or GEHDF5Wrapper no longer includes H5Cpp.h
target_include_directories(data_buildblock PRIVATE ${HDF5_INCLUDE_DIRS})
endif()
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} PRIVATE ${X11_INCLUDE_DIR} ${CURSES_INCLUDE_DIR})
target_link_libraries(${dir} PUBLIC ${X11_LIBRARIES} ${CURSES_LIBRARY})
endif()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "stir/data/SinglesRates.h"
#include "stir/Scanner.h"
#include "stir/Array.h"
#include "stir/IO/GEHDF5Wrapper.h"
#include <string>

using std::string;
Expand All @@ -45,6 +44,8 @@ namespace GE
namespace RDF_HDF5
{

class GEHDF5Wrapper;

/*!
\ingroup recon_buildblock
\ingroup GE
Expand Down Expand Up @@ -135,7 +136,6 @@ class BinNormalisationFromGEHDF5

string normalisation_GEHDF5_filename;
shared_ptr<GEHDF5Wrapper> m_input_hdf5_sptr;
GEHDF5Wrapper h5data;
};

} // namespace RDF_HDF5
Expand Down
5 changes: 5 additions & 0 deletions src/listmode_buildblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ endif()
include(stir_lib_target)

target_link_libraries(listmode_buildblock PUBLIC data_buildblock )

if (HAVE_HDF5)
# for GEHDF5, TODO remove once IO dependency added or GEHDF5Wrapper no longer includes H5Cpp.h
target_include_directories(listmode_buildblock PRIVATE ${HDF5_INCLUDE_DIRS})
endif()
1 change: 1 addition & 0 deletions src/recon_buildblock/BinNormalisationFromGEHDF5.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include "stir/recon_buildblock/BinNormalisationFromGEHDF5.h"
#include "stir/IO/GEHDF5Wrapper.h"
#include "stir/DetectionPosition.h"
#include "stir/DetectionPositionPair.h"
#include "stir/shared_ptr.h"
Expand Down
6 changes: 6 additions & 0 deletions 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 All @@ -160,6 +161,11 @@ if (STIR_WITH_Parallelproj_PROJECTOR)
endif()
endif()

if (HAVE_HDF5)
# for GEHDF5, TODO remove once IO dependency added or GEHDF5Wrapper no longer includes H5Cpp.h
target_include_directories(recon_buildblock PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

if (STIR_WITH_CUDA)
target_link_libraries(recon_buildblock PRIVATE CUDA::cudart)
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 ac0d0b3

Please sign in to comment.