forked from nholthaus/units
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
52 lines (44 loc) · 1.77 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
PROJECT(units)
OPTION(BUILD_TESTS "Build unit tests" ON)
OPTION(BUILD_DOCS "Build the documentation" OFF)
OPTION(DISABLE_IOSTREAM "Disables <iostream> (cout) support for embedded applications" OFF)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# enable parallel build
set( ENV{CL} /MP )
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Increase warning levels
add_compile_options(-Wall -Wextra -pedantic)
endif()
# header-only library target. To use this project as a subdirectory,
# add the following to your code:
#
# add_subdirectory(units) # or whatever you named the directory
# target_link_libraries(${PROJECT_NAME} units)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Remove IOStream from the library (useful for embdedded development)
if(DISABLE_IOSTREAM)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DUNIT_LIB_DISABLE_IOSTREAM)
endif(DISABLE_IOSTREAM)
# unit tests
if(BUILD_TESTS)
set(VERSION_GTEST "1.8.0" CACHE STRING "Google Test framework version")
enable_testing ()
add_subdirectory(3rdParty/gtest)
add_subdirectory(unitTests)
endif(BUILD_TESTS)
# add a target to generate API documentation with Doxygen
if(BUILD_DOCS)
find_package(Doxygen)
if(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc ALL
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
endif(BUILD_DOCS)