Skip to content
Snippets Groups Projects
Commit 9870b093 authored by Pascal Palenda's avatar Pascal Palenda
Browse files

Add common settings for initializing a project

parent 555a8834
Branches
No related tags found
No related merge requests found
......@@ -2,6 +2,8 @@ cmake_minimum_required (VERSION 3.20 FATAL_ERROR)
include_guard ()
include (${CMAKE_CURRENT_LIST_DIR}/InitProject.cmake)
# Check for CPM
file (GLOB CPM_MODULE_LOCATION ${CMAKE_BINARY_DIR}/cmake/CPM*.cmake)
......
include_guard ()
# init_project
#
# Sets common settings for a project. These include:
#
# - all debug builds will have the postfix `-d`
# - the default install directory will be `${CMAKE_CURRENT_BINARY_DIR}/dist`
# - all output directories will include the current configuration
# - IDE folders will be turned on for visual studio
macro (init_project)
set (CMAKE_DEBUG_POSTFIX "-d")
# Set the install root folder if not specified by the user
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (
CMAKE_INSTALL_PREFIX
${CMAKE_CURRENT_BINARY_DIR}/dist
CACHE PATH "Install root directory" FORCE
)
set (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OFF)
endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY AND WIN32)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/bin)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/lib)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/lib)
endif ()
if (CMAKE_GENERATOR MATCHES "Visual Studio")
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
endif ()
endmacro ()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment