Skip to content

Commit ac0d0b3

Browse files
Merge pull request #1518 from KrisThielemans/CMake_restrict_includes
restrict includes for CMake
2 parents 2f521c3 + e88bbf5 commit ac0d0b3

File tree

11 files changed

+26
-14
lines changed

11 files changed

+26
-14
lines changed

src/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ option(BUILD_SHARED_LIBS
3030
if (LLN_FOUND)
3131
set(HAVE_ECAT ON)
3232
message(STATUS "ECAT support enabled.")
33-
include_directories(${LLN_INCLUDE_DIRS})
3433
else()
3534
message(STATUS "ECAT support disabled.")
3635
endif()
@@ -52,7 +51,6 @@ endif()
5251
if ((NOT DISABLE_HDF5) AND HDF5_FOUND)
5352
set(HAVE_HDF5 ON)
5453
message(STATUS "HDF5 support enabled.")
55-
include_directories(${HDF5_INCLUDE_DIRS})
5654
else()
5755
message(STATUS "HDF5 support disabled.")
5856
endif()
@@ -120,7 +118,6 @@ endif()
120118

121119
if (STIR_MPI)
122120
find_package(MPI REQUIRED)
123-
include_directories(${MPI_CXX_INCLUDE_PATH})
124121
# we add MPI_CXX_COMPILE_FLAGS for all files
125122
add_definitions(${MPI_CXX_COMPILE_FLAGS} -DMPICH_IGNORE_CXX_SEEK)
126123
# However, currently we decide to add MPI_CXX_LINK_FLAGS only to those programs that need it,

src/IO/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ endif()
7777
include(stir_lib_target)
7878

7979
if (LLN_FOUND)
80+
target_include_directories(IO PUBLIC ${LLN_INCLUDE_DIRS})
8081
target_link_libraries(IO PUBLIC ${LLN_LIBRARIES})
8182
endif()
8283

@@ -90,6 +91,7 @@ if (CERN_ROOT_FOUND)
9091
endif()
9192

9293
if (HAVE_HDF5)
94+
target_include_directories(IO PUBLIC ${HDF5_INCLUDE_DIRS})
9395
target_link_libraries(IO PUBLIC ${HDF5_CXX_LIBRARIES})
9496
endif()
9597

src/buildblock/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ if (LLN_FOUND)
135135
target_link_libraries(buildblock PUBLIC ${LLN_LIBRARIES})
136136
endif()
137137

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

143143
# TODO currently needed as filters need fourier

src/cmake/STIRConfig.cmake.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,13 @@ if (@HDF5_FOUND@)
102102
find_package(HDF5 @HDF5_VERSION@ QUIET COMPONENTS C CXX)
103103
endif()
104104
find_package(HDF5 @HDF5_VERSION@ REQUIRED COMPONENTS CXX )
105-
include_directories(${HDF5_INCLUDE_DIRS})
106105

107106
set(STIR_BUILT_WITH_HDF5 TRUE)
108107
endif()
109108

110109
if (@LLN_FOUND@)
111110
set(HAVE_ECAT ON)
112111
message(STATUS "ECAT support in STIR enabled.")
113-
# need to add this as stir_ecat7.h etc rely on it
114-
# would be better to add it to STIR_INCLUDE_DIRS (TODO)
115-
include_directories("@LLN_INCLUDE_DIRS@")
116112
set(STIR_BUILT_WITH_LLN_MATRIX TRUE)
117113
endif()
118114

src/data_buildblock/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ endif()
3636
include(stir_lib_target)
3737

3838
target_link_libraries(${dir} PUBLIC buildblock)
39+
40+
if (HAVE_HDF5)
41+
# for GEHDF5, TODO remove once IO dependency added or GEHDF5Wrapper no longer includes H5Cpp.h
42+
target_include_directories(data_buildblock PRIVATE ${HDF5_INCLUDE_DIRS})
43+
endif()

src/display/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ include(stir_lib_target)
4545

4646
if( "${GRAPHICS}" STREQUAL "X")
4747
find_package(Curses REQUIRED)
48-
INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR} ${CURSES_INCLUDE_DIR})
48+
target_include_directories(${dir} PRIVATE ${X11_INCLUDE_DIR} ${CURSES_INCLUDE_DIR})
4949
target_link_libraries(${dir} PUBLIC ${X11_LIBRARIES} ${CURSES_LIBRARY})
5050
endif()
5151

src/include/stir/recon_buildblock/BinNormalisationFromGEHDF5.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "stir/data/SinglesRates.h"
3232
#include "stir/Scanner.h"
3333
#include "stir/Array.h"
34-
#include "stir/IO/GEHDF5Wrapper.h"
3534
#include <string>
3635

3736
using std::string;
@@ -45,6 +44,8 @@ namespace GE
4544
namespace RDF_HDF5
4645
{
4746

47+
class GEHDF5Wrapper;
48+
4849
/*!
4950
\ingroup recon_buildblock
5051
\ingroup GE
@@ -135,7 +136,6 @@ class BinNormalisationFromGEHDF5
135136

136137
string normalisation_GEHDF5_filename;
137138
shared_ptr<GEHDF5Wrapper> m_input_hdf5_sptr;
138-
GEHDF5Wrapper h5data;
139139
};
140140

141141
} // namespace RDF_HDF5

src/listmode_buildblock/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ endif()
5858
include(stir_lib_target)
5959

6060
target_link_libraries(listmode_buildblock PUBLIC data_buildblock )
61+
62+
if (HAVE_HDF5)
63+
# for GEHDF5, TODO remove once IO dependency added or GEHDF5Wrapper no longer includes H5Cpp.h
64+
target_include_directories(listmode_buildblock PRIVATE ${HDF5_INCLUDE_DIRS})
65+
endif()

src/recon_buildblock/BinNormalisationFromGEHDF5.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
#include "stir/recon_buildblock/BinNormalisationFromGEHDF5.h"
29+
#include "stir/IO/GEHDF5Wrapper.h"
2930
#include "stir/DetectionPosition.h"
3031
#include "stir/DetectionPositionPair.h"
3132
#include "stir/shared_ptr.h"

src/recon_buildblock/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ endif()
135135
include(stir_lib_target)
136136

137137
if (STIR_MPI)
138+
target_include_directories(recon_buildblock ${MPI_CXX_INCLUDE_PATH})
138139
target_link_libraries(recon_buildblock PUBLIC ${MPI_CXX_LIBRARIES})
139140
endif()
140141

@@ -160,6 +161,11 @@ if (STIR_WITH_Parallelproj_PROJECTOR)
160161
endif()
161162
endif()
162163

164+
if (HAVE_HDF5)
165+
# for GEHDF5, TODO remove once IO dependency added or GEHDF5Wrapper no longer includes H5Cpp.h
166+
target_include_directories(recon_buildblock PRIVATE ${HDF5_INCLUDE_DIRS})
167+
endif()
168+
163169
if (STIR_WITH_CUDA)
164170
target_link_libraries(recon_buildblock PRIVATE CUDA::cudart)
165171
endif()

0 commit comments

Comments
 (0)