-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
101 lines (87 loc) · 3.32 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
97
98
99
100
101
# Copyright 2016 Gábor Mező ([email protected])
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 2.8)
# Detect if production or developer mode.
# .npmignore excludes "test" directory, so:
set(prod TRUE)
set(testDir "${CMAKE_SOURCE_DIR}/test")
if(EXISTS "${testDir}" AND IS_DIRECTORY "${testDir}")
set(prod FALSE)
endif()
# Configure CCache if available
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
message(STATUS "Using ccache.")
endif()
add_subdirectory(deps/dyncall)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/deps/dyncall/dyncall")
include(DynCallConfig)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/deps/dyncall/dyncallback")
include(DynCallbackConfig)
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/deps/dyncall/dynload")
include(DynLoadConfig)
project (fastcall CXX)
include_directories(
${DYNCALL_INCLUDE_DIRS}
${DYNCALLBACK_INCLUDE_DIRS}
${DYNLOAD_INCLUDE_DIRS}
${CMAKE_JS_INC}
"${CMAKE_SOURCE_DIR}/deps/optional"
"${CMAKE_SOURCE_DIR}/src")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_definitions(-DSOURCE_DIR="${CMAKE_SOURCE_DIR}")
if (DEFINED ENV{FASTCALL_CXX_ARCH})
set(FASTCALL_CXX_ARCH "$ENV{FASTCALL_CXX_ARCH}")
else()
set(FASTCALL_CXX_ARCH "native")
endif()
# add the march/mcpu flag to the compiler if it is supported
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-march=${FASTCALL_CXX_ARCH}" COMPILER_SUPPORTS_MARCH)
if (COMPILER_SUPPORTS_MARCH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${FASTCALL_CXX_ARCH}")
else()
check_cxx_compiler_flag("-mcpu=${FASTCALL_CXX_ARCH}" COMPILER_SUPPORTS_MCPU)
if (COMPILER_SUPPORTS_MCPU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=${FASTCALL_CXX_ARCH}")
endif()
endif()
if(WIN32)
add_definitions(-DNOMINMAX)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -DBOOST_DISABLE_ASSERTS -Ofast -ffast-math -funroll-loops")
else()
message(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)")
endif()
elseif(UNIX)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -DBOOST_DISABLE_ASSERTS -Ofast -ffast-math -funroll-loops")
else()
message(SEND_ERROR "You are on an unsupported platform! (Not Win32 or Unix)")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
message(STATUS "Clang configured.")
endif()
add_subdirectory(deps/ref-cmake)
add_subdirectory(src)
if (NOT prod)
message(STATUS "Developer mode modules added to build configuration.")
add_subdirectory(test/testlib)
add_subdirectory(benchmarks/benchlib)
add_subdirectory(benchmarks/benchmod)
endif()