1
#--------------------------------------------------------------------------------------
2
# This file is part of the Lomse library.
3
# Copyright (c) 2010 Lomse project
5
# Lomse is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software Foundation,
7
# either version 3 of the License, or (at your option) any later version.
9
# Lomse is distributed in the hope that it will be useful, but WITHOUT ANY
10
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License along
14
# with Lomse; if not, see <http://www.gnu.org/licenses/>.
16
# For any comment, suggestion or feature request, please contact the manager of
17
# the project at cecilios@users.sourceforge.net
19
#-------------------------------------------------------------------------------------
20
# This is a CMake configuration file for building makefiles and installfiles for
21
# the library and all test/demo programs
23
# To use it you need CMake which can be downloaded from http://www.cmake.org/
24
#-------------------------------------------------------------------------------------
27
cmake_minimum_required(VERSION 2.6)
30
# Currently this file suppoorts the following generators:
31
# Visual Studio 7 .NET
37
#----------------------------------------------------------------------
38
# Define possible builds
39
#----------------------------------------------------------------------
43
if(CMAKE_GENERATOR MATCHES "CodeBlocks" OR
44
CMAKE_GENERATOR MATCHES "Visual Studio")
46
set(CMAKE_CONFIGURATION_TYPES Debug Release)
47
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
48
"Reset the configurations to what we need" FORCE)
50
set( CMAKE_CONFIGURATION_TYPES RelWithDebInfo )
57
set(CMAKE_CONFIGURATION_TYPES RelWithDebInfo)
58
list(APPEND CMAKE_CONFIGURATION_TYPES Debug Release)
63
#----------------------------------------------------------------------
64
# names for libraries and execs.
65
#----------------------------------------------------------------------
68
set( CMAKE_STATIC_LIBRARY_PREFIX "" )
69
set( CMAKE_STATIC_LIBRARY_SUFFIX ".lib" )
70
set( CMAKE_SHARED_LIBRARY_PREFIX "" )
71
set( CMAKE_SHARED_LIBRARY_SUFFIX ".dll" )
72
set( CMAKE_EXECUTABLE_SUFFIX ".exe" )
78
set( CMAKE_STATIC_LIBRARY_PREFIX "lib" )
79
set( CMAKE_STATIC_LIBRARY_SUFFIX ".a" )
80
set( CMAKE_SHARED_LIBRARY_PREFIX "lib" )
81
set( CMAKE_SHARED_LIBRARY_SUFFIX ".so" )
82
set( CMAKE_EXECUTABLE_SUFFIX "" )
88
#------------------------------------------
90
# "Print all warnings" flag for GCC
92
add_definitions(-Wall -DGCC)
95
# "Link time code generation" flags for MSVC
99
-DWINVER=0x0400 -DWIN32
100
-D_LOMSE_WIN32_VSTUDIO
102
if(${CMAKE_GENERATOR} STREQUAL "Visual Studio 6")
103
add_definitions(-DVC6)
104
elseif(${CMAKE_GENERATOR} STREQUAL "Visual Studio 8 2005")
105
add_definitions(-DVC2005)
106
endif(${CMAKE_GENERATOR} STREQUAL "Visual Studio 6")
110
add_definitions(-D_LOMSE_DEBUG)
114
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
115
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
121
#------------------------------------------
123
set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
124
set(SRC_DIR ${ROOT_DIR}/src )
125
set(MAKEFILES_DIR ${ROOT_DIR}/makefiles )
131
# The build location for libraries and for executables
132
set(EXECUTABLE_OUTPUT_PATH "${ROOT_DIR}/bin")
133
set(LIBRARY_OUTPUT_PATH "${ROOT_DIR}/bin")
137
#////////////////////////////////////////////////////////////////////////
138
# Target: Lomse library
139
#////////////////////////////////////////////////////////////////////////
142
# source files to compile -----------------------------------
145
${SRC_DIR}/parser/lomse_analyser.cpp
146
${SRC_DIR}/parser/lomse_compiler.cpp
147
${SRC_DIR}/parser/lomse_ldp_elements.cpp
148
${SRC_DIR}/parser/lomse_ldp_factory.cpp
149
${SRC_DIR}/parser/lomse_linker.cpp
150
${SRC_DIR}/parser/lomse_model_builder.cpp
151
${SRC_DIR}/parser/lomse_parser.cpp
152
${SRC_DIR}/parser/lomse_reader.cpp
153
${SRC_DIR}/parser/lomse_staffobjs_table.cpp
154
${SRC_DIR}/parser/lomse_tokenizer.cpp
158
${SRC_DIR}/document/lomse_document.cpp
159
${SRC_DIR}/document/lomse_id_assigner.cpp
163
${SRC_DIR}/exporters/lomse_ldp_exporter.cpp
167
${SRC_DIR}/score/lomse_score_iterator.cpp
171
${SRC_DIR}/module/lomse_injectors.cpp
172
${SRC_DIR}/module/lomse_time.cpp
175
set(INTERNAL_MODEL_FILES
176
${SRC_DIR}/internal_model/lomse_basic_model.cpp
177
${SRC_DIR}/internal_model/lomse_basic_objects.cpp
178
${SRC_DIR}/internal_model/lomse_im_figured_bass.cpp
179
${SRC_DIR}/internal_model/lomse_im_note.cpp
180
${SRC_DIR}/internal_model/lomse_internal_model.cpp
184
${SRC_DIR}/mvc/lomse_view.cpp
187
set(GRAPHIC_MODEL_FILES
188
${SRC_DIR}/graphic_model/lomse_document_layouter.cpp
189
${SRC_DIR}/graphic_model/lomse_gm_basic.cpp
190
${SRC_DIR}/graphic_model/lomse_score_layouter.cpp
194
${PARSER_FILES} ${DOCUMENT_FILES} ${EXPORTERS_FILES} ${SCORE_FILES}
195
${MODULE_FILES} ${INTERNAL_MODEL_FILES} ${MVC_FILES}
196
${GRAPHIC_MODEL_FILES}
200
# Adds folders for Visual Studio and other IDEs -----------------------------------
201
source_group( "document" FILES ${DOCUMENT_FILES} )
202
source_group( "exporters" FILES ${EXPORTERS_FILES} )
203
source_group( "graphic_model" FILES ${GRAPHIC_MODEL_FILES} )
204
source_group( "internal_model" FILES ${INTERNAL_MODEL_FILES} )
205
source_group( "module" FILES ${MODULE_FILES} )
206
source_group( "mvc" FILES ${MVC_FILES} )
207
source_group( "parser" FILES ${PARSER_FILES} )
208
source_group( "score" FILES ${SCORE_FILES} )
212
# library makefile generation. Static library
213
#-------------------------------------------------------------
216
add_library( ${LOMSE} STATIC ${ALL_SOURCES} )
219
# hack to remove 'Debug' subdirectory from output path. -------------
220
# see: http://www.cmake.org/Bug/view.php?id=8243
222
set_target_properties(${LOMSE} PROPERTIES PREFIX "../")
225
# once built, place library at lomse/bin
226
set_target_properties(${LOMSE} PROPERTIES
227
RUNTIME_OUTPUT_DIRECTORY ${ROOT_DIR}/bin )
231
# library makefile generation. Dynamic library
232
#-------------------------------------------------------------
234
set(LOMSE_SH lomse_dll)
235
add_library( ${LOMSE_SH} SHARED ${ALL_SOURCES} )
237
# The library target LOMSE_SH has a default OUTPUT_NAME of "lomse_dll", so change it.
238
set_target_properties(${LOMSE_SH} PROPERTIES OUTPUT_NAME "liblomse")
241
# hack to remove 'Debug' subdirectory from output path. --------------
242
# see: http://www.cmake.org/Bug/view.php?id=8243
244
set_target_properties(${LOMSE} PROPERTIES PREFIX "../")
248
#////////////////////////////////////////////////////////////////////////
249
# Target: program for testing the library
250
#////////////////////////////////////////////////////////////////////////
252
set (TESTLIB testlib)
256
${ROOT_DIR}/packages/UnitTest++/src
260
${ROOT_DIR}/packages/UnitTest++/lib
261
${LIBRARY_OUTPUT_PATH}
264
set( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "/NODEFAULTLIB:LIBCD" )
267
# source files to compile -----------------------------------
268
add_executable( ${TESTLIB}
269
${SRC_DIR}/tests/lomse_test_analyser.cpp
270
${SRC_DIR}/tests/lomse_test_colstaffobjs_builder.cpp
271
${SRC_DIR}/tests/lomse_test_compiler.cpp
272
${SRC_DIR}/tests/lomse_test_document.cpp
273
${SRC_DIR}/tests/lomse_test_document_layouter.cpp
274
${SRC_DIR}/tests/lomse_test_elements.cpp
275
${SRC_DIR}/tests/lomse_test_gm_objects.cpp
276
${SRC_DIR}/tests/lomse_test_graphic_model.cpp
277
${SRC_DIR}/tests/lomse_test_internal_model.cpp
278
${SRC_DIR}/tests/lomse_test_model_builder.cpp
279
${SRC_DIR}/tests/lomse_test_parser.cpp
280
${SRC_DIR}/tests/lomse_test_reader.cpp
281
${SRC_DIR}/tests/lomse_test_score_layouter.cpp
282
${SRC_DIR}/tests/lomse_test_stack.cpp
283
${SRC_DIR}/tests/lomse_test_tokenizer.cpp
284
${SRC_DIR}/tests/lomse_test_tree.cpp
285
${SRC_DIR}/tests/lomse_test_view.cpp
286
${SRC_DIR}/tests/lomse_the_test_runner.cpp
290
# libraries to link -----------------------------------
292
target_link_libraries ( ${TESTLIB} liblomse.so UnitTest++.vsnet2003.so )
294
target_link_libraries ( ${TESTLIB} lomse.lib UnitTest++.vsnet2003.lib )
297
# properties -----------------------------------
299
set_target_properties(${TESTLIB} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCD" )
300
set_target_properties(${TESTLIB} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
301
set_target_properties(${TESTLIB} PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
302
set_target_properties(${TESTLIB} PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
303
set_target_properties(${TESTLIB} PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
307
# once generated, run tests
309
TARGET ${TESTLIB} POST_BUILD
310
COMMAND ${EXECUTABLE_OUTPUT_PATH}/debug/testlib.exe
311
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
317
#-----------------------------------------------------------------
319
# install the executable
320
#------------------------------------------
323
# install (TARGETS ${TESTLIB} DESTINATION ${ROOT_DIR}/makefiles/unix )
327
# install (TARGETS ${TESTLIB} DESTINATION ${ROOT_DIR}/makefiles/win32 )
332
# You can change the install location by running cmake like this:
334
# cmake -DCMAKE_INSTALL_PREFIX=/new/install/prefix
336
# By default, the prefix is "/usr/local"
338
#if( UNIX AND NOT APPLE )
339
# install( TARGETS ${LOMSE} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
342
## Set the path of the application executable
344
# set( EXE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/${TESTLIB}${CMAKE_EXECUTABLE_SUFFIX} )
346
# set( EXE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TESTLIB}${CMAKE_EXECUTABLE_SUFFIX} )