| 1 |
cmake_minimum_required(VERSION 3.7) |
| 2 |
|
| 3 |
project(chipmunk) |
| 4 |
|
| 5 |
# to change the prefix, run cmake with the parameter: |
| 6 |
# -D CMAKE_INSTALL_PREFIX=/my/prefix |
| 7 |
|
| 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." |
| 14 |
FORCE) |
| 15 |
endif() |
| 16 |
|
| 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 CACHE STRING "Install location of libraries") |
| 21 |
set(BIN_INSTALL_DIR bin CACHE STRING "Install location of executables") |
| 22 |
|
| 23 |
# other options for the build, you can i.e. activate the shared library by passing |
| 24 |
# -D BUILD_SHARED=ON |
| 25 |
# to cmake. Other options analog |
| 26 |
if(ANDROID) |
| 27 |
option(BUILD_DEMOS "Build the demo applications" OFF) |
| 28 |
option(INSTALL_DEMOS "Install the demo applications" OFF) |
| 29 |
option(BUILD_SHARED "Build and install the shared library" ON) |
| 30 |
option(BUILD_STATIC "Build as static library" ON) |
| 31 |
option(INSTALL_STATIC "Install the static library" OFF) |
| 32 |
else() |
| 33 |
option(BUILD_DEMOS "Build the demo applications" ON) |
| 34 |
option(INSTALL_DEMOS "Install the demo applications" OFF) |
| 35 |
option(BUILD_SHARED "Build and install the shared library" ON) |
| 36 |
option(BUILD_STATIC "Build as static library" ON) |
| 37 |
option(INSTALL_STATIC "Install the static library" ON) |
| 38 |
endif() |
| 39 |
|
| 40 |
if(CMAKE_C_COMPILER_ID STREQUAL "Clang") |
| 41 |
option(FORCE_CLANG_BLOCKS "Force enable Clang blocks" YES) |
| 42 |
endif() |
| 43 |
|
| 44 |
# sanity checks... |
| 45 |
if(INSTALL_DEMOS) |
| 46 |
set(BUILD_DEMOS ON FORCE) |
| 47 |
endif() |
| 48 |
|
| 49 |
# these need the static lib too |
| 50 |
if(BUILD_DEMOS OR INSTALL_STATIC) |
| 51 |
set(BUILD_STATIC ON FORCE) |
| 52 |
endif() |
| 53 |
|
| 54 |
if(NOT MSVC) |
| 55 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") # always use gnu99 |
| 56 |
if(FORCE_CLANG_BLOCKS) |
| 57 |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks") |
| 58 |
endif() |
| 59 |
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math") # extend release-profile with fast-math |
| 60 |
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall") # extend debug-profile with -Wall |
| 61 |
endif() |
| 62 |
|
| 63 |
add_subdirectory(src) |
| 64 |
|
| 65 |
if(BUILD_DEMOS) |
| 66 |
add_subdirectory(demo) |
| 67 |
endif() |