forked from taocpp/PEGTL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (71 loc) · 2.89 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
set(TARGET_NAME "PEGTL")
#=============================================================================
# CMake integration Copyright 2015 Christian Frisson.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
project(PEGTL)
cmake_minimum_required(VERSION 3.0.0)
######################
# OPTIONS #
######################
option(BUILD_SHARED_LIBS "Build ${TARGET_NAME} libraries as shared" OFF)
option(USE_DEBUG "Use Debug" ON)
option(BUILD_DOCUMENTATION "Build ${TARGET_NAME} reference documentation using doxygen (use: make documentation)" OFF)
option(BUILD_APPS "Build apps" OFF)
if(USE_DEBUG)
message( "\nConfigured for Debug Build")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_DEBUG -DTI_DEBUG=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_DEBUG -DTI_DEBUG=1")
if(NOT WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_VERBOSE_MAKEFILE ON)
else(USE_DEBUG)
message( "\nConfigured for Release Build")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTI_DEBUG=0 -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTI_DEBUG=0 -O3")
set(CMAKE_BUILD_TYPE "MinSizeRel")#Debug|Release|RelWithDebInfo|MinSizeRel
set(CMAKE_VERBOSE_MAKEFILE ON)#CF
if(APPLE)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/release")
endif()
endif(USE_DEBUG)
#########################
# INTERNAL DEPENDENCIES #
#########################
# Core dependencies
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
######################
# INTERNAL LIBRARIES #
######################
set(CMAKE_CXX_FLAGS "-std=c++1y ${CMAKE_CXX_FLAGS}")
file(GLOB_RECURSE ${TARGET_NAME}_SRC pegtl/*.cc)
file(GLOB_RECURSE ${TARGET_NAME}_HDR pegtl/*.hh)
add_library(${TARGET_NAME} INTERFACE)# ${${TARGET_NAME}_SRC} ${${TARGET_NAME}_HDR} pegtl.hh)
target_sources(${TARGET_NAME} INTERFACE ${${TARGET_NAME}_HDR} ${CMAKE_CURRENT_SOURCE_DIR}/pegtl.hh)
######################
# APPS #
######################
if(BUILD_APPS)
include_directories(${CURRENT_SOURCE_DIR}/examples)
file(GLOB ${TARGET_NAME}_DEMO_SRCS examples/*.cc)
foreach(${TARGET_NAME}_DEMO_SRC ${${TARGET_NAME}_DEMO_SRCS})
get_filename_component(${TARGET_NAME}_DEMO ${${TARGET_NAME}_DEMO_SRC} NAME_WE)
#message("${TARGET_NAME} demo src ${${TARGET_NAME}_DEMO}")
add_executable(${TARGET_NAME}-example-${${TARGET_NAME}_DEMO} ${${TARGET_NAME}_DEMO_SRC})
target_link_libraries(${TARGET_NAME}-example-${${TARGET_NAME}_DEMO} ${TARGET_NAME})
endforeach()
endif()
######################
# TESTS #
######################
#add_subdirectory(test) #TODO
message("[X] ${TARGET_NAME}")