WIN32 will be ignored on linux, will have to use int __clrcall WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) on windows to hide console window
otherwise plain int main( int, char** ) will suffice
add_executable( name WIN32 )
target_sources( name
PRIVATE
main.cpp
file1.cpp
file2.cpp
header1.hpp
)
target_link_libraries( name
Threads::Threads
custom_library_name_within_this_project
)
set_target_properties( name
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_compile_definitions( name
PRIVATE
DEFINE_NAME=1
)
Libraries
assuming library has public headers in subdirectory ./public/libname/, so it can be included as #include <libname/header.hpp>
add_library( name STATIC )
target_sources( name
PRIVATE
file1.cpp
file2.cpp
some_header.hpp
PUBLIC"${CMAKE_CURRENT_SOURCE_DIR}/public/libname/header.hpp""${CMAKE_CURRENT_SOURCE_DIR}/public/libname/header2.hpp"
)
set_target_properties( name
PROPERTIES
INTERFACE_INCLUDE_DIRECTORY public
)
Config options
build file template build.hpp.in
#pragma once
structBuild {
staticconstexprbool ON = true;
staticconstexprbool OFF = false;
staticconstexprbool option_x = ${OPTION_X};
};