-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
36 lines (30 loc) · 1.66 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
cmake_minimum_required(VERSION 3.9)
project("libargparse")
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
#Only set compiler settings if we are not a sub-project
set(WARN_FLAGS "-Wall -Wextra -Wpedantic -Wcast-qual -Wcast-align -Wshadow -Wformat=2 -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wswitch-default -Wundef -Wunused-variable -Wdisabled-optimization -Wnoexcept -Woverloaded-virtual -Wctor-dtor-privacy -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++14 ${WARN_FLAGS}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
set(FLEX_BISON_WARN_SUPPRESS_FLAGS "-Wno-switch-default -Wno-unused-parameter -Wno-missing-declarations")
endif()
set(LIB_INCLUDE_DIRS src)
file(GLOB_RECURSE LIB_SOURCES src/*.cpp)
file(GLOB_RECURSE LIB_HEADERS src/*.hpp src/*.tpp)
#Create the library
add_library(libargparse STATIC
${LIB_HEADERS}
${LIB_SOURCES})
set_target_properties(libargparse PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
set_target_properties(libargparse PROPERTIES PUBLIC_HEADER "${LIB_HEADERS}")
target_include_directories(libargparse PUBLIC ${LIB_INCLUDE_DIRS})
install(TARGETS libargparse)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
#Create the test executable
add_executable(argparse_test argparse_test.cpp)
target_link_libraries(argparse_test libargparse)
add_test(NAME argparse_test COMMAND argparse_test)
enable_testing()
#Create the example executable
add_executable(argparse_example argparse_example.cpp)
target_link_libraries(argparse_example libargparse)
endif()