-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
81 lines (74 loc) · 3.43 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
##################
### Particules ###
##################
cmake_minimum_required(VERSION 3.9.2)
project(Particules VERSION 0.7.1 DESCRIPTION "A falling-sand-like game using several of my own libraries, C++17, and OpenGL 4.5+")
include(ExternalProject)
# Set mandatory requirements
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CXX_EXTENSIONS YES)
set(USE32BIT FALSE)
set(CMAKE_TOOLCHAIN_FILE 64bit.toolchain)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
option(BUILD_TESTING "Build Unit Tests" ON)
option(CODE_COVERAGE "Enable code coverage reporting for GCC/Clang" OFF)
option(STATIC_ANALYSIS "Enable static code analysis using GCC" OFF)
# Set compilation flags per-compiler
if(MSVC)
set(CMAKE_GENERATOR_PLATFORM x64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /Oi /Ot /GF /Qpar /std:c++17 /Zc:rvalueCast /W4 /WX /permissive-")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Gy /MDd /JMC")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /Ob2 /GL /MD")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG:incremental")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG:FASTLINK /INCREMENTAL:NO")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER Other)
elseif(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Werror -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings -Wno-invalid-token-paste -Wno-unknown-pragmas")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fno-optimize-sibling-calls")
endif()
# Add source files
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
add_subdirectory(external/glfw)
add_subdirectory(external/MiniGFX)
add_subdirectory(external/MiniECS)
add_subdirectory(src)
# Optionally build examples
if(EXAMPLES)
#add_subdirectory( examples/... )
endif()
# Optionally build unit tests
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
# Optionally perform static code analysis tests
if (STATIC_ANALYSIS)
include(CTest)
find_program(MEMORYCHECK_COMMAND valgrind)
if (CTEST_MEMORYCHECK_COMMAND)
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full")
endif()
endif()
endif()
#################
# DOXYGEN CHECK #
#################
option(CONVEXHULL_BUILD_DOCS "Generate documentation" true)
find_package(Doxygen QUIET)
if(DOXYGEN_FOUND AND CONVEXHULL_BUILD_DOCS)
set(DOXYGEN_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/docs/)
set(DOXYGEN_MARKDOWN_SUPPORT YES)
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${PROJECT_SOURCE_DIR}/README.md)
set(DOXYGEN_EXCLUDE ${PROJECT_SOURCE_DIR}/external/ ${PROJECT_SOURCE_DIR}/external/glfw)
doxygen_add_docs(CONVEXHULL_BUILD_DOCS ${PROJECT_SOURCE_DIR} COMMENT "Generate documentation")
endif()