Created
October 31, 2020 11:25
-
-
Save plusangel/9e370e893166dc79cc0c8967871882a1 to your computer and use it in GitHub Desktop.
CMake using conditionals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.17) | |
project(cmake_recipe01 LANGUAGES CXX) | |
set(CMAKE_CXX_STANDARD 14) | |
set(USE_LIBRARY ON) | |
message(STATUS "Compile sources into library? ${USE_LIBRARY}") | |
set(BUILD_SHARED_LIBS OFF) | |
list(APPEND _sources Message.h Message.cpp) | |
if(USE_LIBRARY) | |
add_library(message ${_sources}) | |
add_executable(cmake_recipe01 main.cpp) | |
target_link_libraries(cmake_recipe01 message) | |
else() | |
add_executable(cmake_recipe01 main.cpp ${_sources}) | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment