1- set (SCI_BOOST_INCLUDE "@SCI_BOOST_INCLUDE@" )
2-
3- # These are IMPORTED targets created by FooBarTargets.cmake
4- set (SCI_BOOST_LIBRARY @SCI_BOOST_LIBRARY@)
5- set (SCI_BOOST_LIBRARY_DIR "@SCI_BOOST_LIBRARY_DIR@" )
6- set (SCI_BOOST_USE_FILE "@SCI_BOOST_USE_FILE@" )
1+ # ============================================================================
2+ # BoostConfig.cmake - template for SCIRun superbuild to generate a CMake config file for Boost
3+ # ============================================================================
4+
5+ @PACKAGE_INIT@
6+
7+ set (Boost_FOUND TRUE )
8+
9+ # ---------------------------------------------------------------------------
10+ # Paths
11+ # ---------------------------------------------------------------------------
12+ set (Boost_INCLUDE_DIRS "@SCI_BOOST_INCLUDE@" )
13+ set (Boost_LIBRARY_DIR "@SCI_BOOST_LIBRARY_DIR@" )
14+
15+ # ---------------------------------------------------------------------------
16+ # Helper: define Boost imported library target (cross-platform)
17+ # ---------------------------------------------------------------------------
18+ function (_scirun_define_boost_target lib )
19+ # If Boost already created the target, just ensure includes
20+ if (TARGET Boost::${lib} )
21+ set_target_properties (Boost::${lib} PROPERTIES
22+ INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS} "
23+ )
24+ return ()
25+ endif ()
26+
27+ # Boost.Atomic is header-only on macOS
28+ if (APPLE AND lib STREQUAL "atomic" )
29+ add_library (Boost::atomic INTERFACE IMPORTED )
30+ set_target_properties (Boost::atomic PROPERTIES
31+ INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS} "
32+ )
33+ return ()
34+ endif ()
35+
36+ # Create imported library target
37+ add_library (Boost::${lib} UNKNOWN IMPORTED )
38+ set_target_properties (Boost::${lib} PROPERTIES
39+ INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS} "
40+ )
41+
42+ # Boost.Python static macro (SCIRun convention)
43+ if (lib MATCHES "^python" )
44+ set_target_properties (Boost::${lib} PROPERTIES
45+ INTERFACE_COMPILE_DEFINITIONS BOOST_PYTHON_STATIC_LIB
46+ )
47+ endif ()
48+
49+ # Detect architecture
50+ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
51+ set (_boost_arch "x64" )
52+ else ()
53+ set (_boost_arch "x32" )
54+ endif ()
55+
56+ set (_release_lib "" )
57+ set (_debug_lib "" )
58+
59+ # -------------------------------------------------------------------------
60+ # Windows: SCIRun-built Boost uses tagged .lib names
61+ # -------------------------------------------------------------------------
62+ if (WIN32 )
63+ file (GLOB _all_candidates
64+ "${Boost_LIBRARY_DIR} /libboost_${lib} -*.lib"
65+ )
66+
67+ list (FILTER _all_candidates INCLUDE REGEX "-${_boost_arch} -" )
68+
69+ if (NOT _all_candidates)
70+ message (FATAL_ERROR
71+ "Boost '${lib} ' not found for architecture ${_boost_arch} \n "
72+ "Directory: ${Boost_LIBRARY_DIR} "
73+ )
74+ endif ()
75+
76+ # -----------------------------------------------------------------------
77+ # ABI-aware Debug / Release selection (Boost 1.8+)
78+ #
79+ # Rules:
80+ # - Debug libraries contain '-g'
81+ # - Release libraries do NOT contain '-g'
82+ # - 'y' means Python enabled and may appear in BOTH
83+ # -----------------------------------------------------------------------
84+
85+ # Debug candidates
86+ set (_dbg_candidates "${_all_candidates} " )
87+ list (FILTER _dbg_candidates INCLUDE REGEX "-g" )
88+
89+ if (_dbg_candidates)
90+ list (GET _dbg_candidates 0 _debug_lib)
91+ endif ()
92+
93+ # Release candidates
94+ set (_rel_candidates "${_all_candidates} " )
95+ list (FILTER _rel_candidates EXCLUDE REGEX "-g" )
96+
97+ if (_rel_candidates)
98+ list (GET _rel_candidates 0 _release_lib)
99+ endif ()
100+
101+ # -------------------------------------------------------------------------
102+ # macOS / Linux
103+ # -------------------------------------------------------------------------
104+ else ()
105+ file (GLOB _all_candidates
106+ "${Boost_LIBRARY_DIR} /libboost_${lib} .a"
107+ "${Boost_LIBRARY_DIR} /libboost_${lib} -mt.a"
108+ "${Boost_LIBRARY_DIR} /libboost_${lib} .dylib"
109+ "${Boost_LIBRARY_DIR} /libboost_${lib} -mt.dylib"
110+ )
111+
112+ if (NOT _all_candidates)
113+ message (FATAL_ERROR
114+ "Boost library '${lib} ' could not be resolved.\n "
115+ "Directory: ${Boost_LIBRARY_DIR} \n "
116+ "Platform: ${CMAKE_SYSTEM_NAME } "
117+ )
118+ endif ()
119+
120+ list (GET _all_candidates 0 _release_lib)
121+ set (_debug_lib "${_release_lib} " )
122+ endif ()
123+
124+ # -------------------------------------------------------------------------
125+ # Fail fast if resolution failed
126+ # -------------------------------------------------------------------------
127+ if (NOT _release_lib OR NOT _debug_lib)
128+ message (FATAL_ERROR
129+ "Boost library '${lib} ' could not be resolved for both configurations.\n "
130+ "All candidates:\n ${_all_candidates} "
131+ )
132+ endif ()
133+
134+ set_target_properties (Boost::${lib} PROPERTIES
135+ IMPORTED_CONFIGURATIONS "Release;Debug"
136+ IMPORTED_LOCATION_RELEASE "${_release_lib} "
137+ IMPORTED_LOCATION_DEBUG "${_debug_lib} "
138+ )
139+ endfunction ()
140+
141+ # ---------------------------------------------------------------------------
142+ # Core Boost components
143+ # ---------------------------------------------------------------------------
144+ _scirun_define_boost_target (atomic )
145+ _scirun_define_boost_target (chrono )
146+ _scirun_define_boost_target (date_time )
147+ _scirun_define_boost_target (filesystem )
148+ _scirun_define_boost_target (program_options )
149+ _scirun_define_boost_target (regex )
150+ _scirun_define_boost_target (serialization )
151+ _scirun_define_boost_target (thread )
152+
153+ # ---------------------------------------------------------------------------
154+ # Boost.Python (optional)
155+ # ---------------------------------------------------------------------------
156+ if (@BUILD_WITH_PYTHON@)
157+ _scirun_define_boost_target (python@SCI_PYTHON_VERSION_SHORT_WIN32@ )
158+ endif ()
159+
160+ # ---------------------------------------------------------------------------
161+ # Compatibility variables
162+ # ---------------------------------------------------------------------------
163+ set (Boost_LIBRARIES
164+ Boost::atomic
165+ Boost::chrono
166+ Boost::date_time
167+ Boost::filesystem
168+ Boost::program_options
169+ Boost::regex
170+ Boost::serialization
171+ Boost::thread
172+ )
173+
174+ add_library (Boost::headers INTERFACE IMPORTED )
175+ set_target_properties (Boost::headers PROPERTIES
176+ INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS} "
177+ )
178+
179+ if (@BUILD_WITH_PYTHON@)
180+ list (APPEND Boost_LIBRARIES Boost::python@SCI_PYTHON_VERSION_SHORT_WIN32@)
181+ endif ()
0 commit comments