-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
62 lines (48 loc) · 1.62 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
53
54
55
56
57
58
59
60
61
62
cmake_minimum_required(VERSION 2.8.4)
project(cpp_colors)
enable_testing()
set(WARNINGS)
# Platform
if(UNIX)
option(BUILD_TESTS "Build tests." ON)
option(BUILD_EXAMPLES "Build examples." ON)
elseif(WIN32)
option(BUILD_TESTS "Build tests." ON)
option(BUILD_EXAMPLES "Build examples." ON)
add_definitions(-DUNICODE -D_UNICODE)
else()
message(FATAL_ERROR "-- Unsupported Build Platform.")
endif()
# Compiler
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
message("-- Setting clang options")
set(WARNINGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing")
set(STRICT_CXX_FLAGS ${WARNINGS} "-Werror -pedantic")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
message("-- Setting gcc options")
set(WARNINGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing")
set(STRICT_CXX_FLAGS ${WARNINGS} "-Werror -pedantic")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
message("-- Setting msvc options")
else()
message("-- Unknown compiler, success is doubtful.")
endif()
# Reconfigure final output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
include_directories(include)
if(BUILD_TESTS)
add_subdirectory(test)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# Clean the entire build directory
add_custom_target(clean-all
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/../clean-all.cmake
)