1 cmake_minimum_required(VERSION 3.7)
5 # to change the prefix, run cmake with the parameter:
6 # -D CMAKE_INSTALL_PREFIX=/my/prefix
8 # to change the build type, run cmake with the parameter:
9 # -D CMAKE_BUILD_TYPE=<build-type>
10 # run "cmake --help-variable CMAKE_BUILD_TYPE" for details
11 if(NOT CMAKE_BUILD_TYPE)
12 SET(CMAKE_BUILD_TYPE Release CACHE STRING
13 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
17 # to manually select install locations of libraries and executables
18 # -D LIB_INSTALL_DIR mylib
19 # -D BIN_INSTALL_DIR newbin
20 set(LIB_INSTALL_DIR ${LIB_DIR} CACHE STRING "Install location of libraries")
21 set(BIN_INSTALL_DIR bin CACHE STRING "Install location of executables")
23 # other options for the build, you can i.e. activate the shared library by passing
25 # to cmake. Other options analog
27 option(BUILD_SHARED "Build and install the shared library" ON)
28 option(BUILD_STATIC "Build as static library" ON)
29 option(INSTALL_STATIC "Install the static library" OFF)
31 option(BUILD_SHARED "Build and install the shared library" ON)
32 option(BUILD_STATIC "Build as static library" ON)
33 option(INSTALL_STATIC "Install the static library" ON)
36 if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
37 option(FORCE_CLANG_BLOCKS "Force enable Clang blocks" YES)
41 set(BUILD_STATIC ON FORCE)
45 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") # always use gnu99
46 if(FORCE_CLANG_BLOCKS)
47 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks")
49 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math") # extend release-profile with fast-math
50 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall") # extend debug-profile with -Wall