-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
61 lines (46 loc) · 1.68 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
# minimum required cmake version
cmake_minimum_required( VERSION 3.5 FATAL_ERROR )
# project name
project( vfgs )
set( EXE_NAME vfgs )
# get source files
file( GLOB SRC_FILES "${CMAKE_SOURCE_DIR}/src/*.c" )
# use ccache
find_program( CCACHE_FOUND ccache )
if( CCACHE_FOUND )
message( STATUS "ccache found. using it." )
set_property( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
set_property( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache )
endif()
# set default CMAKE_BUILD_TYPE to Release if not set
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE )
endif()
if( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
set( USE_ADDRESS_SANITIZER OFF CACHE BOOL "Compiles with -sanitize=address and links to libasan" )
endif()
endif()
if( CMAKE_COMPILER_IS_GNUCC )
set( BUILD_STATIC OFF CACHE BOOL "Build static executables" )
endif()
include_directories(${CMAKE_SOURCE_DIR}/src)
# Enable warnings for some generators and toolsets.
if( MSVC )
# CMake 3.11.0 introduces support for generator expression COMPILE_LANGUAGE.
# MSVC generator does not support the generator expression COMPILE_LANGUAGE yet.
#string( APPEND CMAKE_CXX_FLAGS " warnings-as-errors /wd4996" )
string( APPEND CMAKE_C_FLAGS " /WX /wd4996" )
else()
add_compile_options( "-Werror" )
endif()
# enable sse4.1 build for all source files for gcc and clang
if( UNIX OR MINGW )
add_compile_options( "-msse4.1" )
endif()
# enable parallel build for Visual Studio
if( MSVC )
add_compile_options( "/MP" )
add_compile_options( "/EHsc" )
endif()
add_executable( ${EXE_NAME} ${SRC_FILES})