From 15a622d90b60b07b18f77d11c8bceed1442ef7ea Mon Sep 17 00:00:00 2001 From: johannst Date: Sat, 4 Nov 2023 20:34:17 +0000 Subject: deploy: f2b0515fdd1cb84bebe24cac59498b682b49de80 --- development/cmake.html | 262 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 development/cmake.html (limited to 'development/cmake.html') diff --git a/development/cmake.html b/development/cmake.html new file mode 100644 index 0000000..40ee607 --- /dev/null +++ b/development/cmake.html @@ -0,0 +1,262 @@ + + + + + + cmake - Notes + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + +
+
+

cmake(1)

+

PRIVATE / PUBLIC / INTERFACE

+

These modifier control where properties for a given target are visible.

+
    +
  • PRIVATE: Only for the target itself.
  • +
  • PUBLIC: For the target itself and anyone linking against it.
  • +
  • INTERFACE: Only for anyone linking against the target.
  • +
+

The following gives an example for preprocessor definitions specified on a +library target. This behaves in the same way for other properties like for +example include directories.

+
# CMakeLists.txt
+
+cmake_minimum_required(VERSION 3.14)
+project(moose)
+
+# -- LIBRARY
+add_library(liba STATIC liba.cc)
+target_compile_definitions(liba PUBLIC DEF_PUBLIC)
+target_compile_definitions(liba PRIVATE DEF_PRIVATE)
+target_compile_definitions(liba INTERFACE DEF_INTERFACE)
+
+# -- APPLICATION
+add_executable(main main.cc)
+target_link_libraries(main liba)
+
+
> touch liba.cc; echo "int main() {}" > main.cc
+> cmake -B build -S . -G Ninja
+> ninja -C build -j1 --verbose
+[1/4] /usr/bin/c++ -DDEF_PRIVATE -DDEF_PUBLIC  [..] .../liba.cc
+[2/4] [..]
+[3/4] /usr/bin/c++ -DDEF_INTERFACE -DDEF_PUBLIC [..] .../main.cc
+[4/4] [..]
+
+ +
+ + +
+
+ + + +
+ + + + + + + + + + + + + + + + + + +
+ + -- cgit v1.2.3