-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathCMakeLists.txt
111 lines (92 loc) · 3.81 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
102
103
104
105
106
107
108
109
110
111
cmake_minimum_required(VERSION 2.8.3)
#set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
project(Toucan)
#Find wxWidgets
find_package(wxWidgets COMPONENTS net adv aui stc scintilla core base REQUIRED)
include(${wxWidgets_USE_FILE})
#Find boost
#set(BOOST_ROOT "E:/dev/tools/boost_1_54_0")
set(BOOST_ROOT "" CACHE PATH "Path to directory with Boost library")
set(Boost_USE_STATIC_LIBS "ON")
#find_package(Boost REQUIRED)
find_package(Boost COMPONENTS thread system REQUIRED)
add_definitions(-DBOOST_DATE_TIME_NO_LIB)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
#Find Lua
find_package(Lua51 REQUIRED)
include_directories(${LUA_INCLUDE_DIR})
#Find SWIG
find_package(SWIG REQUIRED)
#Find Google Test
find_package(GTest)
if(MSVC)
#Ask if we are using a static CRT
set(Toucan_Static FALSE CACHE BOOL "Should we use the static CRT?")
#Disable security warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
#Set the warning level to maximum
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
if(Toucan_Static)
#We statically link to reduce dependancies
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
endif(Toucan_Static)
endif(MSVC)
if(MINGW)
# Under MinGW we want to add these flags
# -std=gnu++11 enables C++11 support with GNU extensions (otherwise it doesn't compile)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif(MINGW)
#Traverse through the sub-directories
add_subdirectory(backup)
add_subdirectory(controls)
add_subdirectory(data)
add_subdirectory(forms)
add_subdirectory(secure)
add_subdirectory(sync)
add_subdirectory(test)
#Link against them
link_directories(backup)
link_directories(controls)
link_directories(data)
link_directories(forms)
link_directories(secure)
link_directories(sync)
#toucan_wrap.cpp is generated by SWIG
set_source_files_properties(toucan_wrap.cpp PROPERTIES GENERATED true)
#Add the source and header files
set(source ${source} basicfunctions.cpp dragndrop.cpp filecounter.cpp fileops.cpp)
set(source ${source} job.cpp log.cpp luamanager.cpp luathread.cpp path.cpp rules.cpp settings.cpp)
set(source ${source} signalprocess.cpp toucan.cpp toucan_wrap.cpp)
set(headers ${headers} basicfunctions.h dragndrop.h filecounter.h fileops.h)
set(headers ${headers} job.h log.h luamanager.h luathread.h path.h rules.h settings.h)
set(headers ${headers} signalprocess.h toucan.h)
set(headers ${headers} toucan.i typemaps.i)
if(WIN32)
#Add the resource file for the icon
set(source ${source} toucan.rc)
endif(WIN32)
#Generate toucan_wrap.cpp using swig
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/toucan_wrap.cpp
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/toucan.i
COMMAND ${SWIG_EXECUTABLE} -o ${CMAKE_CURRENT_SOURCE_DIR}/toucan_wrap.cpp -lua -c++ ${CMAKE_CURRENT_SOURCE_DIR}/toucan.i
)
#Set up the exe
add_executable(toucan ${source} ${headers})
#target_link_libraries(toucan forms backup controls data secure sync ${wxWidgets_LIBRARIES} ${LUA_LIBRARIES})
target_link_libraries(toucan forms backup controls data secure sync ${wxWidgets_LIBRARIES} ${LUA_LIBRARIES} ${Boost_LIBRARIES})
#Once we have built Toucan move it somewhere suitable
set(Toucan_Output "" CACHE PATH "The path to an existing Toucan installation")
set(Toucan_Exepath ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/toucan${CMAKE_EXECUTABLE_SUFFIX})
add_custom_command(
TARGET toucan
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${Toucan_Exepath} ${Toucan_Output}/App/Toucan/toucan${CMAKE_EXECUTABLE_SUFFIX}
)