2021-08-19 06:29:11 +00:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2023-07-12 00:24:11 +00:00
|
|
|
project(peglib)
|
2019-11-21 16:52:31 +00:00
|
|
|
|
2020-10-02 01:26:04 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-11-21 16:52:31 +00:00
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
2016-06-01 10:30:26 +00:00
|
|
|
|
2020-10-02 01:26:04 +00:00
|
|
|
if(MSVC)
|
2022-08-20 17:17:31 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /utf-8 /D_CRT_SECURE_NO_DEPRECATE")
|
2021-01-19 17:03:06 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
2016-06-01 10:30:26 +00:00
|
|
|
endif()
|
|
|
|
|
2020-06-20 12:43:15 +00:00
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads)
|
|
|
|
|
2016-06-07 08:29:45 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
2020-05-17 14:55:56 +00:00
|
|
|
set(add_link_deps Threads::Threads)
|
2016-06-07 08:29:45 +00:00
|
|
|
endif()
|
|
|
|
|
2023-07-12 00:24:11 +00:00
|
|
|
add_library(peglib INTERFACE)
|
2024-05-02 09:31:31 +00:00
|
|
|
target_include_directories(peglib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
2021-08-17 23:13:31 +00:00
|
|
|
|
2023-07-12 00:24:11 +00:00
|
|
|
option(BUILD_TESTS "Build cpp-peglib tests" ON)
|
|
|
|
option(PEGLIB_BUILD_LINT "Build cpp-peglib lint utility" OFF)
|
|
|
|
option(PEGLIB_BUILD_EXAMPLES "Build cpp-peglib examples" OFF)
|
2024-06-17 17:03:53 +00:00
|
|
|
option(PEGLIB_BUILD_PL0 "Build pl0 interpreter" OFF)
|
2022-07-02 02:15:21 +00:00
|
|
|
|
2022-11-13 13:51:22 +00:00
|
|
|
if (${BUILD_TESTS})
|
2022-06-25 12:21:25 +00:00
|
|
|
add_subdirectory(test)
|
|
|
|
enable_testing()
|
|
|
|
endif()
|
2020-10-02 01:26:04 +00:00
|
|
|
|
2023-07-12 00:24:11 +00:00
|
|
|
if (${PEGLIB_BUILD_LINT})
|
|
|
|
add_subdirectory(lint)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (${PEGLIB_BUILD_EXAMPLES})
|
|
|
|
add_subdirectory(example)
|
|
|
|
endif()
|
|
|
|
|
2024-06-17 17:03:53 +00:00
|
|
|
if (${PEGLIB_BUILD_PL0})
|
|
|
|
add_subdirectory(pl0)
|
|
|
|
endif()
|
|
|
|
|
2020-03-15 18:37:42 +00:00
|
|
|
install(FILES peglib.h DESTINATION include)
|