1
0
Fork 0
mirror of https://github.com/TheLartians/ModernCppStarter.git synced 2025-08-31 22:21:13 +02:00
ModernCppStarter/standalone/CMakeLists.txt
ClausKlein 6ea6bdd2ea add options.cmake project config file
common options used for every cmake project
prevent reame of standalone executable via cmake properties
2021-02-17 10:31:56 +01:00

38 lines
1,007 B
CMake

cmake_minimum_required(VERSION 3.14...3.19)
project(GreeterStandalone LANGUAGES CXX)
# --- Import tools ----
include(../cmake/tools.cmake)
# ---- Dependencies ----
include(../cmake/CPM.cmake)
CPMUsePackageLock(package-lock.cmake)
CPMAddPackage(
NAME cxxopts
GITHUB_REPOSITORY jarro2783/cxxopts
VERSION 2.2.0
OPTIONS "CXXOPTS_BUILD_EXAMPLES Off" "CXXOPTS_BUILD_TESTS Off"
)
CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
# ---- Create standalone executable ----
file(GLOB sources CONFIGURE_DEPENDS source/*.cpp)
add_executable(GreeterStandalone ${sources})
set_target_properties(GreeterStandalone PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD})
# WORKAROUND missing ALIAS target error! CK
if(NOT TARGET cxxopts::cxxopts)
add_library(cxxopts::cxxopts ALIAS cxxopts)
endif()
target_link_libraries(GreeterStandalone Greeter::Greeter cxxopts::cxxopts)
# ---- run the standalone executable ----
enable_testing()
add_test(NAME GreeterStandalone COMMAND GreeterStandalone)