-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
204 lines (158 loc) · 5.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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#-------------------------------------------------------------------------------------
# This is a CMake configuration file for building the langtool program
#
# To use it you need CMake which can be downloaded from http://www.cmake.org/
#-------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------
# This file is part of LenMus project.
# Copyright (c) 2002-2019 Cecilio Salmeron
#
# LenMus is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Lomse is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Lomse; if not, see <http://www.gnu.org/licenses/>.
#
# For any comment, suggestion or feature request, please contact the manager of
# the project at [email protected]
#
#-------------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.10)
# Project name.
project(langtool)
# check that compiler supports namespace sdt
include(TestForSTDNamespace)
if(CMAKE_NO_STD_NAMESPACE)
message(FATAL_ERROR "The compiler doesn't support namespace std.")
endif()
# force to use c++11
if (CMAKE_VERSION VERSION_LESS "3.1")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else ()
set(CMAKE_CXX_STANDARD 11) #require c+11 or greater
set(CMAKE_CXX_STANDARD_REQUIRED ON) #prevent fallback to any previous standard
endif ()
#check that the compiler supports c++11 and std::regex
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 4.9
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
message(FATAL_ERROR "GCC version must be at least 4.9!")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# require at least clang 3.4
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
message(FATAL_ERROR "Clang version must be at least 3.4!")
endif()
else()
message(WARNING "** Warning **: You are using an untested compiler! Lomse has only been tested with GCC and Clang.")
endif()
# set directories
set( LANGTOOL_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
set( OUTDIR ${LANGTOOL_DIR}/z_bin )
set( EXECUTABLE_OUTPUT_PATH ${OUTDIR} )
set( PACKAGES_DIR ${LANGTOOL_DIR}/packages )
include_directories(
${LANGTOOL_DIR}/src
${PACKAGES_DIR}/wxXml2/include
)
#set platform
if(WIN32)
set( LANGTOOL_PLATFORM_WIN32 "1")
set( LANGTOOL_PLATFORM_UNIX "0")
elseif(UNIX)
set( LANGTOOL_PLATFORM_WIN32 "0")
set( LANGTOOL_PLATFORM_UNIX "1")
endif()
#set compiler
if(MSVC)
set( LANGTOOL_COMPILER_MSVC "1")
set( LANGTOOL_COMPILER_GCC "0")
elseif(CMAKE_COMPILER_IS_GNUCC)
set( LANGTOOL_COMPILER_MSVC "0")
set( LANGTOOL_COMPILER_GCC "1")
endif()
#Check wxWidgets
#http://docs.wxwidgets.org/2.8/wx_librarieslist.html
SET( wxWidgets_USE_LIBS aui base gl net richtext xml xrc core adv html)
FIND_PACKAGE(wxWidgets REQUIRED)
IF(wxWidgets_FOUND)
#include_directories( ${wxWidgets_INCLUDE_DIRS} )
INCLUDE(${wxWidgets_USE_FILE})
IF(UNIX)
set(wxWidgets_CXX_FLAGS "`wx-config --cflags -D__WXGTK__ -D_UNICODE`")
ENDIF(UNIX)
ENDIF(wxWidgets_FOUND)
#Check for libxml2 and libiconv
FIND_PACKAGE(LibXml2 REQUIRED)
include_directories( ${LIBXML2_INCLUDE_DIR} )
message(STATUS "LIBXML2_LIBRARIES => " ${LIBXML2_LIBRARIES})
message(STATUS "LIBXML2_INCLUDE_DIR => " ${LIBXML2_INCLUDE_DIR})
# "Print all warnings", macros for GCC & __UNIX__
if(UNIX)
add_definitions( -Wall -DGCC -D__UNIX__ )
endif(UNIX)
message(STATUS "wxWidgets => " ${wxWidgets_LIBRARIES} )
#define a header file to pass CMake settings to source code
configure_file(
"${LANGTOOL_DIR}/langtool_config.h.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/langtool_config.h"
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
link_directories(
${LIBRARY_OUTPUT_PATH}
)
# source files to compile
#--------------------------------------------------------------
set( SRC_DIR ${LANGTOOL_DIR}/src )
set( WXXML2_DIR ${PACKAGES_DIR}/wxXml2 )
message(STATUS "SRC_DIR => " ${SRC_DIR})
message(STATUS "WXXML2_DIR => " ${WXXML2_DIR})
set(LANGTOOL_FILES
${SRC_DIR}/command.cpp
${SRC_DIR}/command.h
${SRC_DIR}/dlg_compile_book.cpp
${SRC_DIR}/dlg_compile_book.h
${SRC_DIR}/ebook_processor.cpp
${SRC_DIR}/ebook_processor.h
${SRC_DIR}/help_processor.cpp
${SRC_DIR}/help_processor.h
${SRC_DIR}/installer.cpp
${SRC_DIR}/installer.h
${SRC_DIR}/langtool.cpp
# ${SRC_DIR}/langtool.rc
${SRC_DIR}/main_frame.cpp
${SRC_DIR}/main_frame.h
${SRC_DIR}/paths.cpp
${SRC_DIR}/paths.h
)
set(WXXML2_FILES
${WXXML2_DIR}/src/dtd.cpp
${WXXML2_DIR}/include/wx/dtd.h
${WXXML2_DIR}/src/xml2.cpp
${WXXML2_DIR}/include/wx/xml2.h
)
set(ALL_SOURCES
${LANGTOOL_FILES} ${WXXML2_FILES}
)
# Adds folders for Visual Studio and other IDEs
source_group( "langtool" FILES ${LANGTOOL_FILES} )
source_group( "wxXml2" FILES ${WXXML2_FILES} )
# langtool program generation
#-------------------------------------------------------------
set(LANGTOOL langtool)
add_executable( ${LANGTOOL} ${ALL_SOURCES} )
# link to the necessary libraries
target_link_libraries ( ${LANGTOOL}
${wxWidgets_LIBRARIES}
${LIBXML2_LIBRARIES}
)
message(STATUS "wxWidgets libraries => " ${wxWidgets_LIBRARIES})
message(STATUS "LibXml2 libraries => " ${LIBXML2_LIBRARIES})
# once built, place executable at langtool/z_bin
set_target_properties(${LANGTOOL} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} )