Skip to content

Commit c1e1923

Browse files
authored
Update ch_cmconfig.md
1 parent e2d6a10 commit c1e1923

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pages/ch_cmconfig.md

+19
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,25 @@ Adding yet another unrelated source tree to the project requires declaring it in
305305
NCBI_declare_module_root("$ENV{HOME}/project2")
306306
NCBI_add_subdirectory(${NCBITK_SRC_ROOT} src $ENV{HOME}/project2)
307307

308+
Finally, if your build target is defined in the current directory and there is no subdirectories, the definition must be put into a separate CMake file and the target must be declared in advance.
309+
For example, to define *mytest* application, create *CMakeLists.mytest.app.txt* file:
310+
311+
NCBI_begin_app(mytest)
312+
NCBI_sources(mytest.cpp)
313+
NCBI_uses_toolkit_libraries(xncbi)
314+
NCBI_end_app()
315+
316+
and the root *CMakeLists.txt*:
317+
318+
cmake_minimum_required(VERSION 3.20)
319+
project(test)
320+
include($ENV{HOME}/src/build-system/cmake/CMake.NCBItoolkit.cmake)
321+
NCBI_declare_target(mytest.app)
322+
NCBI_add_subdirectory(${NCBITK_SRC_ROOT})
323+
NCBI_add_target(mytest.app)
324+
325+
Note that the target is *declared* before adding ${NCBITK_SRC_ROOT} and *defined* after that.
326+
308327

309328
<aname="ch_cmconfig._related"></a>
310329

0 commit comments

Comments
 (0)
close