forked from BitFunnel/NativeJIT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
89 lines (68 loc) · 2.87 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
# NativeJIT
cmake_minimum_required(VERSION 2.6)
# Remove the warning that WIN32 is not defined in Cygwin any more.
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
# Project-wide settings for NativeJIT
project(NativeJIT CXX C)
if (WIN32 OR CYGWIN)
set(NATIVEJIT_PLATFORM_POSIX 0)
set(NATIVEJIT_PLATFORM_WINDOWS 1)
else()
set(NATIVEJIT_PLATFORM_POSIX 1)
set(NATIVEJIT_PLATFORM_WINDOWS 0)
endif()
if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
message(STATUS "######################################## NativeJIT is root")
else()
message(STATUS "######################################## BitFunnel is root")
set(NATIVEJIT_PREFIX "NativeJIT/")
endif (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
if(NATIVEJIT_PLATFORM_WINDOWS)
# Note: -D works for both MSVC and GCC/Clang.
set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -DNATIVEJIT_PLATFORM_WINDOWS")
else()
set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -DNATIVEJIT_PLATFORM_POSIX")
endif()
set(GTEST_REQUIRED_FLAGS "-Wno-shift-sign-overflow -Wno-missing-noreturn -Wno-used-but-marked-unused -Wno-deprecated -Wno-missing-variable-declarations -Wno-global-constructors -Wno-weak-vtables -Wno-undef")
set(WEVERYTHING_FLAGS "-Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic ${GTEST_REQUIRED_FLAGS}")
if(MSVC)
set(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} /W4 /WX -D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_CXX_FLAGS} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMMON_CXX_FLAGS} /MT")
elseif(CMAKE_COMPILER_IS_GNUCXX)
# Need gnu++ instead of c++ so that GTest can access fdopen() etc.
set(CMAKE_CXX_FLAGS "-march=native -std=gnu++14 -Wall -Wextra -Werror -Wold-style-cast -fstrict-aliasing -Wstrict-aliasing")
else()
# TODO: define a target for -Weverything.
# set(CMAKE_CXX_FLAGS "-msse4.2 -std=c++14 -Wall -Wextra -Werror -Wold-style-cast ${WEVERYTHING_FLAGS}")
set(CMAKE_CXX_FLAGS "-march=native -std=c++14 -Wall -Wextra -Werror -Wold-style-cast")
endif()
###############################################################################
# gtest
if(NativeJIT_BUILD_TESTS)
add_subdirectory(googletest)
include_directories(
${gtest_SOURCE_DIR}/include
)
endif()
###############################################################################
# This allows the solution to group projects into folders like src and test.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(NativeJIT_BUILD_TESTS)
enable_testing()
add_subdirectory(test/CodeGen)
add_subdirectory(test/NativeJIT)
add_subdirectory(test/Shared)
add_subdirectory(Examples) # ...
endif()
add_subdirectory(src/CodeGen)
add_subdirectory(src/NativeJIT)
add_custom_target(TOPLEVEL_NATIVEJIT SOURCES
Configure_Make.bat
Configure_Make.sh
Configure_MSVC.bat
LICENSE.txt
README.md
)
set(ENV{GTEST_COLOR} 1)
# add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)