Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
CMakeLists_root.txt 1.45 KiB
cmake_minimum_required(VERSION 3.7)

project(alib2
	VERSION {alib_versioning_major}.{alib_versioning_minor}.{alib_versioning_patch}
	LANGUAGES C CXX)

set(CMAKE_MODULE_PATH ${{CMAKE_SOURCE_DIR}}/CMake/Modules)
set(CONFIGURE_HEADERS_SRC_DIR ${{CMAKE_SOURCE_DIR}}/CMake/headers)
set(CONFIGURE_HEADERS_DST_DIR ${{CMAKE_BINARY_DIR}}/generated)
include_directories(${{CONFIGURE_HEADERS_DST_DIR}})

set(CMAKE_COLOR_MAKEFILE ON)
# set(CMAKE_VERBOSE_MAKEFILE ON) # use VERBOSE=1 target

# Immediately fail if not UNIX
# TODO: Add suport for other platforms. Check MacOS
if (NOT UNIX)
    message(FATAL_ERROR "Unavailable if not Unix")
endif ()

# If not specified whether Debug or Release, select debug. Fail if invalid.
# cmake -DCMAKE_BUILD_TYPE={{Release,Debug}}
if (NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
endif ()
if (NOT CMAKE_BUILD_TYPE MATCHES "(Release|Debug)")
	message(FATAL_ERROR "Unsupported build type")
endif()

# versioning
include(versioning)

# compile options based on compiler/build_type. Also add sanitizer support
include(CompilerFlags)

# install paths
include(Install)

# testing
enable_testing()
add_subdirectory(contrib/catch2)

# list projects
set(ALIB_MODULES_LIB
        {alib_modules_lib}
        )

set(ALIB_MODULES_EXE
        {alib_modules_exe}
        )
set(ALIB_MODULES_TEST
        {alib_modules_test}
        )

foreach (module ${{ALIB_MODULES_LIB}} ${{ALIB_MODULES_EXE}} ${{ALIB_MODULES_TEST}})
    add_subdirectory(${{module}})
endforeach ()