-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
118 lines (104 loc) · 4.11 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
cmake_minimum_required(VERSION 3.17)
set(MAJOR_VERSION 1)
project(
parafeed
VERSION ${MAJOR_VERSION}.0.0
LANGUAGES CXX C)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
# Set a default build type if none was specified
set(default_build_type Release)
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(default_build_type Debug)
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS
"Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
# Set a default install prefix
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
AND NOT WIN32
AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_INSTALL_PREFIX
"/opt/nrao.edu/${PROJECT_NAME}" CACHE PATH "..." FORCE)
endif()
# initialize install RPATH
if(APPLE)
set(base @loader_path)
else()
set(base $ORIGIN)
endif()
file(RELATIVE_PATH relDir
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_INSTALL_RPATH ${base} ${base}/${relDir})
# build dependencies
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
# link dependencies
find_package(PkgConfig REQUIRED)
# c++11 is required
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Allow setting the ABI on commandline. If not set on commandline,
# use complier's default ABI.
if (DEFINED _GLIBCXX_USE_CXX11_ABI)
list(APPEND CMAKE_MESSAGE_INDENT " ")
message("Building with -D_GLIBCXX_USE_CXX11_ABI=${_GLIBCXX_USE_CXX11_ABI}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${_GLIBCXX_USE_CXX11_ABI}")
else()
list(APPEND CMAKE_MESSAGE_INDENT " ")
message("Building with the complier default ABI setting")
endif()
#pkg_search_module(readline REQUIRED
# IMPORTED_TARGET readline)
#get_target_property(_readline_interface_include_dirs
# PkgConfig::readline INTERFACE_INCLUDE_DIRECTORIES)
add_library(readline SHARED IMPORTED)
#set_target_properties(readline PROPERTIES IMPORTED_LOCATION /usr/lib/x86_64-linux-gnu/libreadline.so)
set_target_properties(readline PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/include)
# work around a problem in which the readline.pc file declares
# "Requires.private: termcap", which prevents setting the
# INTERFACE_INCLUDE_DIRECTORIES property of PkgConfig::readline
#if(NOT _readline_interface_include_dirs)
# # search for the include directory based on the library location
# get_target_property(_readline_interface_link_libs
# PkgConfig::readline INTERFACE_LINK_LIBRARIES)
# get_filename_component(_readline_interface_link_libs
# "${_readline_interface_link_libs}" DIRECTORY)
# get_filename_component(_readline_interface_link_libs
# "${_readline_interface_link_libs}" DIRECTORY)
# set(_readline_interface_include_dirs
# "${_readline_interface_link_libs}/include")
# # basically now library_path/../../include, check for
# # readline/readline.h in this directory
# find_file(_has_readline_h
# readline.h
# HINTS "${_readline_interface_include_dirs}/readline")
# if(_has_readline_h)
# # found it, set the property
# message(STATUS
# "Applying workaround for readline.pc private termcap dependence")
# set_target_properties(PkgConfig::readline
# PROPERTIES
# INTERFACE_INCLUDE_DIRECTORIES "${_readline_interface_include_dirs}")
# endif()
#endif()
# code sub-directory
add_subdirectory(code)
message("top: CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}")
message("top: CMAKE_CURRENT_BINARY_DIR = ${CMAKE_CURRENT_BINARY_DIR}")
# install all parafeed exports
include(CMakePackageConfigHelpers)
write_basic_package_version_file(parafeedConfigVersion.cmake
VERSION 0
COMPATIBILITY AnyNewerVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/parafeedConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/parafeed)
# Generate the parafeed.pc file
configure_file(parafeed.pc.in ${CMAKE_INSTALL_LIBDIR}/pkgconfig/parafeed.pc @ONLY)