forked from MADEAPPS/newton-dynamics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (80 loc) · 3.52 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright (c) <2014> <Newton Game Dynamics>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely.
cmake_minimum_required(VERSION 2.8.8)
project(NewtonSDK)
# Use relative paths
# This is mostly to reduce path size for command-line limits on windows
if(WIN32)
# This seems to break Xcode projects so definitely don't enable on Apple builds
set(CMAKE_USE_RELATIVE_PATHS true)
set(CMAKE_SUPPRESS_REGENERATION true)
endif()
# Include necessary submodules
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
#####################################################################
# Set up the basic build environment
#####################################################################
if (CMAKE_BUILD_TYPE STREQUAL "")
# CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
# differentiation between debug and release builds.
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()
if (NOT APPLE)
# Create debug libraries with _d postfix
set(CMAKE_DEBUG_POSTFIX "_d")
endif ()
if (MSVC)
if (CMAKE_BUILD_TOOL STREQUAL "nmake")
# set variable to state that we are using nmake makefiles
set(NMAKE TRUE)
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
# Enable intrinsics on MSVC in debug mode
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Oi")
if (CMAKE_CL_64)
# Visual Studio bails out on debug builds in 64bit mode unless
# this flag is set...
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj")
endif ()
if (MSVC_VERSION GREATER 1600 OR MSVC_VERSION EQUAL 1600)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif ()
endif ()
# Specify build paths
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${NewtonSDK_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${NewtonSDK_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${NewtonSDK_BINARY_DIR}/bin")
if (WIN32 OR APPLE)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# We don't want to install in default system location, install is really for the SDK, so call it that
set(CMAKE_INSTALL_PREFIX "${NewtonSDK_SOURCE_DIR}/sdk" CACHE PATH "Newton SDK install directory prefix" FORCE)
endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif ()
###################################################################
# disable (useless) compiler warnings on project level
###################################################################
if(MSVC)
add_definitions( /wd4786 /wd4503 /wd4251 /wd4275 /wd4290 /wd4661 /wd4996 /wd4127 /wd4100)
endif()
# determine if we are compiling for a 32bit or 64bit system
include(CheckTypeSize)
CHECK_TYPE_SIZE("void*" PTR_SIZE BUILTIN_TYPES_ONLY)
if (PTR_SIZE EQUAL 8)
set(BUILD_64 TRUE)
else ()
set(BUILD_64 FALSE)
endif ()
option("NEWTON_DEMOS_SANDBOX" "Build demos sandbox" ON)
add_subdirectory("${NewtonSDK_SOURCE_DIR}/coreLibrary_300")
add_subdirectory("${NewtonSDK_SOURCE_DIR}/packages")
if(NEWTON_DEMOS_SANDBOX)
add_subdirectory("${NewtonSDK_SOURCE_DIR}/applications/demosSandbox")
endif()