-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
69 lines (60 loc) · 2.14 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
# Base project setup.
project(edvonhack)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Get the target CPU from the user.
set(TARGET_CPU "x86" CACHE STRING "Select a target CPU")
set_property(CACHE TARGET_CPU PROPERTY STRINGS
"x86" "x64")
if(${TARGET_CPU} STREQUAL "x86")
set(LIB_FOLDER_POSTFIX "")
elseif(${TARGET_CPU} STREQUAL "x64")
set(LIB_FOLDER_POSTFIX "64")
endif()
# Retrieve the current operating system.
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(TARGET_OS "linux")
elseif(WIN32)
set(TARGET_OS "win32")
endif()
# Set compiler flags.
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_definitions("-std=c++11 -Wall -Wextra -Weffc++")
if(${TARGET_CPU} STREQUAL "x86")
add_definitions("-DEDVONHACK_CPU_X86")
set(EXE_COMPILE_FLAGS "-m32")
set(LIB_COMPILE_FLAGS "-m32")
set(EXE_LINK_FLAGS "-m32")
set(LIB_LINK_FLAGS "-m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -m32")
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS
"${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32")
elseif(${TARGET_CPU} STREQUAL "x64")
add_definitions("-DEDVONHACK_CPU_X64")
set(EXE_COMPILE_FLAGS "-m64")
set(LIB_COMPILE_FLAGS "-m64")
set(EXE_LINK_FLAGS "-m64")
set(LIB_LINK_FLAGS "-m64")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -m64")
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS
"${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m64")
endif()
if(${TARGET_OS} STREQUAL "linux")
add_definitions("-DEDVONHACK_OS_LINUX")
elseif(${TARGET_OS} STREQUAL "win32")
add_definitions("-DEDVONHACK_OS_WIN32")
endif()
endif()
# Set common include directories.
include_directories(
${CMAKE_SOURCE_DIR}/libedvonhack/include
)
# Compile the parts of Ed von Hack.
add_subdirectory(libedvonhack)
add_subdirectory(driver)
option(RUN_UNITTETS "Compile and run unit tests" ON)
if(RUN_UNITTETS)
add_subdirectory(unittest)
endif()