prj-dir
|CMakeList.txt
|src/*.c,*cpp
|inc/*.h,*.hpp
`bin/<executable files>
# linux
$ cmake -GNinja
# macOS
$ cmake -GNinja CMakeLists.txt -D CMAKE_CXX_COMPILER=/usr/bin/g++
$ ninja
$ ./runcmd
cmake_minimum_required(VERSION 3.20) | |
project( my_app CXX ) | |
# lib | |
add_library( other OBJECT src/other.cpp) | |
# add_library( other STATIC src/other.cpp ) | |
target_include_directories( other PRIVATE ./inc) | |
target_compile_options( other PUBLIC -w -Wall ) | |
target_compile_features( other PUBLIC cxx_std_17) | |
# if STATIC,SHARE set_target_properties( other PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ./lib) | |
# bin | |
add_executable(runcmd src/main.cpp) | |
target_compile_options( runcmd PUBLIC -w -Wall ) | |
target_compile_features( runcmd PUBLIC cxx_std_17) | |
target_link_libraries(runcmd other ) | |
target_include_directories(runcmd PRIVATE ./inc) |