forked from argtable/argtable3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (93 loc) · 4.43 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
################################################################################
# This file is part of the argtable3 library.
#
# Copyright (C) 2016-2021 Tom G. Huang
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of STEWART HEITMANN nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL STEWART HEITMANN BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
################################################################################
cmake_minimum_required(VERSION 3.5)
set(ARGTABLE3_PROJECT_NAME "argtable3")
set(ARGTABLE3_PACKAGE_NAME "Argtable3")
project(${ARGTABLE3_PROJECT_NAME} "C")
option(BUILD_SHARED_LIBS "Build shared library" OFF)
option(ARGTABLE3_ENABLE_CONAN "Enable Conan dependency manager" OFF)
option(ARGTABLE3_ENABLE_TESTS "Enable unit tests" ON)
option(ARGTABLE3_ENABLE_EXAMPLES "Enable examples" ON)
option(ARGTABLE3_ENABLE_ARG_REX_DEBUG "Enable arg_rex debug output" OFF)
option(ARGTABLE3_REPLACE_GETOPT "Replace getopt in the system C library" ON)
option(ARGTABLE3_LONG_ONLY "Use getopt_long_only instead of getopt_long" OFF)
get_filename_component(VERSION_TAG_PATH "version.tag" ABSOLUTE)
if(EXISTS ${VERSION_TAG_PATH})
file(READ version.tag VERSION_TAG OFFSET 1)
string(REPLACE "." ";" VERSION_LIST ${VERSION_TAG})
list(GET VERSION_LIST 0 PROJECT_VERSION_MAJOR)
list(GET VERSION_LIST 1 PROJECT_VERSION_MINOR)
list(GET VERSION_LIST 2 PROJECT_VERSION_PATCH)
list(GET VERSION_LIST 3 PROJECT_VERSION_BUILD)
else()
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 0)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_BUILD "mainline")
endif()
set(PROJECT_VERSION_TWEAK 0)
set(ARGTABLE3_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK})
set(ARGTABLE3_FULL_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_BUILD})
if(ARGTABLE3_ENABLE_CONAN AND EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup()
string(REPLACE ";" ":" LINK_FLAGS "${CONAN_LIB_DIRS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath-link,${LINK_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,${LINK_FLAGS}")
endif()
set(ARGTABLE3_AMALGAMATION_SRC_FILE ${PROJECT_SOURCE_DIR}/dist/argtable3.c)
set(ARGTABLE3_SRC_FILES
${PROJECT_SOURCE_DIR}/src/arg_cmd.c
${PROJECT_SOURCE_DIR}/src/arg_date.c
${PROJECT_SOURCE_DIR}/src/arg_dbl.c
${PROJECT_SOURCE_DIR}/src/arg_dstr.c
${PROJECT_SOURCE_DIR}/src/arg_end.c
${PROJECT_SOURCE_DIR}/src/arg_file.c
${PROJECT_SOURCE_DIR}/src/arg_hashtable.c
${PROJECT_SOURCE_DIR}/src/arg_int.c
${PROJECT_SOURCE_DIR}/src/arg_lit.c
${PROJECT_SOURCE_DIR}/src/arg_rem.c
${PROJECT_SOURCE_DIR}/src/arg_rex.c
${PROJECT_SOURCE_DIR}/src/arg_str.c
${PROJECT_SOURCE_DIR}/src/arg_utils.c
${PROJECT_SOURCE_DIR}/src/argtable3.c
${PROJECT_SOURCE_DIR}/src/arg_getopt_long.c
)
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()
add_subdirectory(src)
if(ARGTABLE3_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
if(ARGTABLE3_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()