You are on page 1of 1

cmake_minimum_required(VERSION 3.14.

0)
project(CMAKE_TEMPLATE VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 17)

# Require out-of-source builds


file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if(EXISTS "${LOC_PATH}")
message(FATAL_ERROR "You cannot build in a source directory (or any directory
with a CMakeLists.txt file). \
Please make a build subdirectory. Feel free to remove CMakeCache.txt and
CMakeFiles.")
endif()

# Set build type


set(default_build_type "Debug")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was
specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

# adding subdirectories
add_subdirectory(thirdparty)
add_subdirectory(include)
add_subdirectory(src)

# Testing
include(CTest)
enable_testing()
option(BUILD_TESTS "OFF if you don't want to buid tests" ON)

if(BUILD_TESTS)
message(STATUS "BUILD_TESTS option is ON")
add_subdirectory(tests)
endif()

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

# install(
# EXPORT simpleLibrary
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake
# )

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

You might also like