@@ -178,34 +178,13 @@ This is a small sample program that uses the module ``std``. It consists of a
178178 )
179179 FetchContent_MakeAvailable(std)
180180
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-
204181 #
205182 # Add the project
206183 #
207184
208185 add_executable(main)
186+ add_dependencies(main std.compat)
187+ target_link_libraries(main std.compat)
209188 target_sources(main
210189 PRIVATE
211190 main.cpp
@@ -218,13 +197,9 @@ Building this project is done with the following steps, assuming the files
218197
219198 $ mkdir build
220199 $ cmake -G Ninja -S . -B build -DCMAKE_CXX_COMPILER=< path-to-compiler> -DLIBCXX_BUILD=< build>
221- $ ninja -j1 std -C build
222200 $ ninja -C build
223201 $ build/main
224202
225- .. note :: The ``std`` dependencies of ``std.compat`` is not always resolved when
226- building the ``std `` target using multiple jobs.
227-
228203 .. warning :: ``<path-to-compiler>`` should point point to the real binary and
229204 not to a symlink.
230205
0 commit comments