-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
160 lines (144 loc) · 4.5 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
cmake_minimum_required(VERSION 2.7)
project(map_template)
FILE(GLOB SRC map_template/src/*.c*)
FILE(GLOB INCLUDE map_template/include/*.h)
set(wxWidgets_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wxWidgets-3.1.0)
set(wxBuildDependecy wxBuild_Flag)
set(wxLibDebug
wxmsw31ud_gl.lib
wxmsw31ud_core.lib
wxbase31ud.lib
wxtiffd.lib
wxjpegd.lib
wxpngd.lib
wxzlibd.lib
wxregexud.lib
wxexpatd.lib
)
set(wxLibRelease
wxmsw31u_gl.lib
wxmsw31u_core.lib
wxbase31u.lib
wxtiff.lib
wxjpeg.lib
wxpng.lib
wxzlib.lib
wxregexu.lib
wxexpat.lib
)
set(CommonLibs
comdlg32.lib
winmm.lib
shlwapi.lib
comctl32.lib
ole32.lib
rpcrt4.lib
version.lib
wsock32.lib
wininet.lib
)
set(wxConfHeaders
setup.h
)
find_path( MYSQL_INCLUDE_DIR
NAMES "mysql.h"
PATHS "$ENV{PROGRAMFILES}/MySQL/*/include"
"$ENV{PROGRAMFILES(x86)}/MySQL/*/include"
"$ENV{SYSTEMDRIVE}/MySQL/*/include" )
find_library( MYSQL_LIBRARY
NAMES "libmysql.lib"
PATHS "$ENV{PROGRAMFILES}/MySQL/*/lib"
"$ENV{PROGRAMFILES(x86)}/MySQL/*/lib"
"$ENV{SYSTEMDRIVE}/MySQL/*/lib" )
find_library( MYSQLCONN_LIBRARY
NAMES "mysqlcppconn.lib"
PATHS "$ENV{PROGRAMFILES}/MySQL/*/lib/opt"
"$ENV{PROGRAMFILES(x86)}/MySQL/*/lib/opt"
"$ENV{SYSTEMDRIVE}/MySQL/*/lib/opt" )
add_custom_command(
OUTPUT ${wxBuildDependecy}
COMMAND if not exist ${CMAKE_CURRENT_SOURCE_DIR}/build/wxBuild
nmake.exe -f makefile.vc clean
COMMAND if not exist ${CMAKE_CURRENT_SOURCE_DIR}/build/wxBuild
echo $null >> ${CMAKE_CURRENT_SOURCE_DIR}/build/wxBuild
COMMAND nmake.exe -f makefile.vc SHARED=0 BUILD=debug
COMMAND nmake.exe -f makefile.vc SHARED=0 BUILD=release
WORKING_DIRECTORY ${wxWidgets_ROOT_DIR}/build/msw
COMMENT "Build wx"
VERBATIM
)
add_custom_target(wxBuild DEPENDS ${wxBuildDependecy})
set_property(
SOURCE ${wxBuild_Flag}
PROPERTY SYMBOLIC 1
)
# generate wrapper headers for foo.h and bar.h
foreach(hdr ${wxConfHeaders})
# find a good include guard name
string(TOUPPER "${hdr}" incguard)
string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" incguard
"PROXY_HDR_${incguard}")
# write the proxy header
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/build/include/wx/${hdr}"
"
/* AUTOMATICALLY GENERATED BY CMAKE -- DO NOT EDIT! */
#pragma once
#ifndef ${incguard}
#define ${incguard}
/* if building debug configuration, include Debug/${hdr},
otherwise Optimized/${hdr} */
#if defined(CONFIG_DEBUG)
# include \"${wxWidgets_ROOT_DIR}/lib/vc_lib/mswud/wx/${hdr}\"
#else
# include \"${wxWidgets_ROOT_DIR}/lib/vc_lib/mswu/wx/${hdr}\"
#endif
#endif
")
endforeach()
# set up the definitions for the switch yard
set_directory_properties(PROPERTIES
COMPILE_DEFINITIONS_DEBUG CONFIG_DEBUG
COMPILE_DEFINITIONS_RELEASE CONFIG_RELEASE
COMPILE_DEFINITIONS_RELWITHDEBINFO CONFIG_RELWITHDEBINFO
COMPILE_DEFINITIONS_MINSIZEREL CONFIG_MINSIZE_REL)
# set up the include directories so our proxy headers and the actual
# headers can be found by the preprocessor
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/map_template/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Eigen)
include_directories(${wxWidgets_ROOT_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/include)
include_directories(${MYSQL_INCLUDE_DIR})
link_directories(${wxWidgets_ROOT_DIR}/lib/vc_lib)
add_executable(${PROJECT_NAME} ${SRC} ${INCLUDE})
add_dependencies(${PROJECT_NAME} wxBuild)
target_link_libraries(${PROJECT_NAME} ${CommonLibs})
target_link_libraries(${PROJECT_NAME} ${MYSQL_LIBRARY})
target_link_libraries(${PROJECT_NAME} ${MYSQLCONN_LIBRARY})
foreach(lib ${wxLibDebug})
target_link_libraries(${PROJECT_NAME} debug ${lib} )
endforeach()
foreach(lib ${wxLibRelease})
target_link_libraries(${PROJECT_NAME} optimized ${lib})
endforeach()
target_link_libraries(${PROJECT_NAME} ${Libraries})
if(WIN32)
if(MSVC)
set_target_properties(map_template PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
else()
message(SEND_ERROR "MSVC Required")
endif()
else()
message(SEND_ERROR "WIN32 only")
endif()
################################
# GTest
################################
ADD_SUBDIRECTORY (googletest)
enable_testing()
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ${MYSQL_INCLUDE_DIR})
################################
FILE(GLOB SRC_test tests/*.c*)
SET(CMAKE_CXX_FLAGS_DEBUG /MTd)
add_executable(${PROJECT_NAME}_test ${SRC_test} ${INCLUDE})
target_link_libraries(${PROJECT_NAME}_test gtest gtest_main ${MYSQL_LIBRARY} ${MYSQLCONN_LIBRARY})
add_test( ${PROJECT_NAME}_test ${PROJECT_NAME}_test )