-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
63 lines (51 loc) · 2.53 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
cmake_minimum_required(VERSION 2.6)
project(MAMEduino)
#-------------------------------------------------------------------------------
#set up compiler flags and excutable names
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") #multi-processor compilation
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") #multi-processor compilation
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
#check for G++ 4.7+
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE G++_VERSION)
if (G++_VERSION VERSION_LESS 4.7)
message(SEND_ERROR "You need at least G++ 4.7 to compile MAMEduino!")
endif()
#set up compiler flags for GCC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2") #support C++11 for std::, optimize
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s") #strip binary
endif()
#-------------------------------------------------------------------------------
#define basic sources and headers
set(TARGET_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/consolestyle.h
${CMAKE_CURRENT_SOURCE_DIR}/src/MAMEduino.h
)
set(TARGET_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/consolestyle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/MAMEduino.cpp
)
#-------------------------------------------------------------------------------
#set up build directories
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
#-------------------------------------------------------------------------------
#define target
add_executable(mameduino ${TARGET_SOURCES} ${TARGET_HEADERS})
#-------------------------------------------------------------------------------
#special properties for windows builds
if(MSVC)
#create console application
#Note that up to CMake 2.8.11.2 this feature is broken: http://public.kitware.com/Bug/view.php?id=12566
set_target_properties(mameduino PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(mameduino PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
set_target_properties(mameduino PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(mameduino PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
set_target_properties(mameduino PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:CONSOLE")
set_target_properties(mameduino PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:CONSOLE")
endif()