@@ -178,34 +178,13 @@ This is a small sample program that uses the module ``std``. It consists of a
178
178
)
179
179
FetchContent_MakeAvailable(std)
180
180
181
- #
182
- # Adjust project compiler flags
183
- #
184
-
185
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fprebuilt-module-path=${std_BINARY_DIR}/CMakeFiles/std.dir/>)
186
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-fprebuilt-module-path=${std_BINARY_DIR}/CMakeFiles/std.compat.dir/>)
187
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-nostdinc++>)
188
- # The include path needs to be set to be able to use macros from headers.
189
- # For example from, the headers <cassert> and <version>.
190
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-isystem>)
191
- add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${LIBCXX_BUILD}/include/c++/v1>)
192
-
193
- #
194
- # Adjust project linker flags
195
- #
196
-
197
- add_link_options($<$<COMPILE_LANGUAGE:CXX>:-nostdlib++>)
198
- add_link_options($<$<COMPILE_LANGUAGE:CXX>:-L${LIBCXX_BUILD}/lib>)
199
- add_link_options($<$<COMPILE_LANGUAGE:CXX>:-Wl,-rpath,${LIBCXX_BUILD}/lib>)
200
- # Linking against the standard c++ library is required for CMake to get the proper dependencies.
201
- link_libraries(std c++)
202
- link_libraries(std.compat c++)
203
-
204
181
#
205
182
# Add the project
206
183
#
207
184
208
185
add_executable(main)
186
+ add_dependencies(main std.compat)
187
+ target_link_libraries(main std.compat)
209
188
target_sources(main
210
189
PRIVATE
211
190
main.cpp
@@ -218,13 +197,9 @@ Building this project is done with the following steps, assuming the files
218
197
219
198
$ mkdir build
220
199
$ cmake -G Ninja -S . -B build -DCMAKE_CXX_COMPILER=< path-to-compiler> -DLIBCXX_BUILD=< build>
221
- $ ninja -j1 std -C build
222
200
$ ninja -C build
223
201
$ build/main
224
202
225
- .. note :: The ``std`` dependencies of ``std.compat`` is not always resolved when
226
- building the ``std `` target using multiple jobs.
227
-
228
203
.. warning :: ``<path-to-compiler>`` should point point to the real binary and
229
204
not to a symlink.
230
205
0 commit comments