2016-11-09 13:04:56 +01:00
cmake_minimum_required ( VERSION 3.2.2 )
project ( Parsodus VERSION 1.0 )
2016-11-25 16:30:56 +01:00
set ( CMAKE_CXX_STANDARD 14 )
set ( CMAKE_CXX_STANDARD_REQUIRED 14 )
2016-11-09 13:04:56 +01:00
2016-11-27 14:49:28 +01:00
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } ${ CMAKE_CURRENT_SOURCE_DIR } /cmake )
2016-11-09 13:04:56 +01:00
include ( ExternalProject )
find_package ( mstch QUIET )
if ( NOT mstch_FOUND )
ExternalProject_Add ( ext-mstch
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / n o 1 m s d / m s t c h
G I T _ T A G 1 . 0 . 2
#The following line is a dirty hack
#to prevent cmake from needlessly clone any submodule
#inspect `ext-mstch-prefix/tmp/ext-mstch-gitclone.cmake` for more info
G I T _ S U B M O D U L E S " N O N E \ C O M M A N D \ t r u e \ E R R O R _ Q U I E T "
C M A K E _ A R G S - D W I T H _ U N I T _ T E S T S = N O
I N S T A L L _ C O M M A N D " "
)
add_library ( mstch::mstch IMPORTED STATIC GLOBAL )
add_dependencies ( mstch::mstch ext-mstch )
ExternalProject_Get_Property ( ext-mstch source_dir binary_dir )
set_target_properties ( mstch::mstch PROPERTIES "IMPORTED_LOCATION" "${binary_dir}/src/${CMAKE_STATIC_LIBRARY_PREFIX}mstch${CMAKE_STATIC_LIBRARY_SUFFIX}" )
include_directories ( ${ source_dir } /include )
endif ( )
ExternalProject_Add ( ext-optparse
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / m y i n t / o p t p a r s e
C O N F I G U R E _ C O M M A N D " "
B U I L D _ C O M M A N D " "
I N S T A L L _ C O M M A N D " "
)
ExternalProject_Get_Property ( ext-optparse source_dir )
include_directories ( ${ source_dir } )
2016-11-27 14:06:26 +01:00
find_program ( LEXESIS_EXE Lexesis )
if ( NOT LEXESIS_EXE_FOUND )
2017-01-20 13:28:09 +01:00
#Lexesis
2016-11-27 14:06:26 +01:00
ExternalProject_Add ( ext-lexesis
G I T _ R E P O S I T O R Y g i t @ g i t l a b . c o m : R o b i n _ J a d o u l / L e x e s i s . g i t
)
2017-01-20 13:28:09 +01:00
add_library ( templ IMPORTED STATIC GLOBAL )
add_dependencies ( templ ext-lexesis )
ExternalProject_Get_Property ( ext-lexesis binary_dir source_dir )
set_target_properties ( templ PROPERTIES "IMPORTED_LOCATION" "${binary_dir}/src/${CMAKE_STATIC_LIBRARY_PREFIX}templ${CMAKE_STATIC_LIBRARY_SUFFIX}" )
include_directories ( ${ source_dir } /include )
2016-11-27 14:06:26 +01:00
set ( LEXESIS_EXE "${binary_dir}/bin/Lexesis" )
endif ( )
2016-11-27 14:49:28 +01:00
#Enable code coverage on debug
if ( CMAKE_BUILD_TYPE MATCHES Debug )
option ( USE_SYSTEM_LCOV "Use the lcov version found on the system, if available" YES )
include ( CodeCoverage )
if ( NOT LCOV_PATH OR NOT USE_SYSTEM_LCOV )
ExternalProject_Add ( ext-lcov
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / l i n u x - t e s t - p r o j e c t / l c o v
C O N F I G U R E _ C O M M A N D " "
B U I L D _ C O M M A N D " "
I N S T A L L _ C O M M A N D " "
T E S T _ C O M M A N D " " )
if ( ${ CMAKE_VERSION } STRGREATER "3.0.1" )
set_target_properties ( ext-lcov PROPERTIES EXCLUDE_FROM_ALL 1 )
endif ( )
ExternalProject_Get_Property ( ext-lcov source_dir )
set ( LCOV_PATH "${source_dir}/bin/lcov" )
set ( GENHTML_PATH "${source_dir}/bin/genhtml" )
endif ( )
SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage" )
endif ( )
option ( USE_SYSTEM_GTEST "Use the google test framework installed on the system, if available" YES )
find_package ( GTest )
if ( NOT GTEST_FOUND OR NOT USE_SYSTEM_GTEST )
#Google test framework
ExternalProject_Add ( ext-gtest
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / g o o g l e / g o o g l e t e s t . g i t
C M A K E _ A R G S - D B U I L D _ G M O C K = N O - D B U I L D _ G T E S T = Y E S
I N S T A L L _ C O M M A N D " "
)
add_library ( gtest IMPORTED STATIC GLOBAL )
add_dependencies ( gtest ext-gtest )
add_library ( gtest_main IMPORTED STATIC GLOBAL )
add_dependencies ( gtest_main ext-gtest )
ExternalProject_Get_Property ( ext-gtest source_dir binary_dir )
find_package ( Threads )
set_target_properties ( gtest PROPERTIES
" I M P O R T E D _ L O C A T I O N " " $ { b i n a r y _ d i r } / g o o g l e t e s t / $ { C M A K E _ S T A T I C _ L I B R A R Y _ P R E F I X } g t e s t $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X } "
" I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S " " $ { C M A K E _ T H R E A D _ L I B S _ I N I T } "
)
set_target_properties ( gtest_main PROPERTIES
" I M P O R T E D _ L O C A T I O N " " $ { b i n a r y _ d i r } / g o o g l e t e s t / $ { C M A K E _ S T A T I C _ L I B R A R Y _ P R E F I X } g t e s t _ m a i n $ { C M A K E _ S T A T I C _ L I B R A R Y _ S U F F I X } "
" I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S " " $ { C M A K E _ T H R E A D _ L I B S _ I N I T } "
)
include_directories ( ${ source_dir } /googletest/include )
set ( GTEST_LIBRARIES gtest )
set ( GTEST_BOTH_LIBRARIES gtest_main gtest )
else ( )
find_package ( GTest REQUIRED )
find_package ( Threads REQUIRED )
include_directories ( GTEST_INCLUDE_DIRS )
set ( GTEST_BOTH_LIBRARIES gtest_main gtest ${ CMAKE_THREAD_LIBS_INIT } )
endif ( )
2016-11-09 13:04:56 +01:00
##########################################
find_package ( Doxygen )
if ( DOXYGEN_FOUND )
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /Doxyfile.in ${ CMAKE_CURRENT_BINARY_DIR } /Doxyfile @ONLY )
add_custom_target ( doc ${ DOXYGEN_EXECUTABLE } ${ CMAKE_CURRENT_BINARY_DIR } /Doxyfile WORKING_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } COMMENT "Generating API documentation" VERBATIM )
endif ( DOXYGEN_FOUND )
set ( CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}" )
2016-11-27 14:49:28 +01:00
##Warning level
if ( ${ CMAKE_CXX_COMPILER_ID } STREQUAL "GNU" OR ${ CMAKE_CXX_COMPILER_ID } STREQUAL "Clang" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic" )
elseif ( ${ CMAKE_CXX_COMPILER_ID } STREQUAL "MSVC" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" )
endif ( )
2016-11-09 13:04:56 +01:00
include_directories ( include )
add_subdirectory ( src )
2017-01-21 11:05:25 +01:00
add_dependencies ( Parsodus ext-optparse )
2016-11-27 14:49:28 +01:00
enable_testing ( )
add_subdirectory ( tests )
2017-01-21 11:05:25 +01:00
add_subdirectory ( examples )
2016-11-09 13:04:56 +01:00
install ( DIRECTORY templates
D E S T I N A T I O N s h a r e / P a r s o d u s
)
# add_subdirectory(examples)