-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
111 lines (95 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
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE FALSE)
project(ufecppbinding)
set(project_prefix UFECPP)
include(cmake/submodule.cmake)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS NO)
if(${CMAKE_CXX_COMPILER_VERSION} MATCHES "^3.+" OR "${CMAKE_CXX_COMPILER_VERSION}" MATCHES "^4.+")
message(ERROR "!!! unsupported compiler version, require >= GCC 5+, but only found ${CMAKE_CXX_COMPILER_VERSION}")
endif()
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Generate debug library name with a postfix.")
include(cmake/macros.cmake)
find_version(_version _soversion)
option(${project_prefix}_ENABLE_ADDRESS_SANITIZER "enable address sanitizer (default=no)" OFF)
include(cmake/gcc.cmake)
include(cmake/msvc.cmake)
include_directories(include)
include_directories(${CMAKE_BINARY_DIR}/include)
message("-- version === ${_version} / ${_soversion}")
set(zmq_include "$<BUILD_INTERFACE:${${project_prefix}_ZMQ_PATH}/include>")
set(cppzmq_include "$<BUILD_INTERFACE:${${project_prefix}_CPPZMQ_PATH}>")
set(protobuf_include "$<BUILD_INTERFACE:${${project_prefix}_PROTOBUF_PATH}/src>")
set(protobuf_compiler $<TARGET_FILE:protoc>)
set(protobuf_path $<TARGET_FILE_DIR:protoc>)
add_custom_command(
OUTPUT
${CMAKE_BINARY_DIR}/include/ufecpp/ufeapi.pb.h
${CMAKE_BINARY_DIR}/include/ufecpp/ufeapi.pb.cc
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/ufecpp
COMMAND ${CMAKE_COMMAND} -E env ${_ld_library_path}=${protobuf_path} ${protobuf_compiler} --cpp_out=${CMAKE_BINARY_DIR}/include/ufecpp ufeapi.proto
MAIN_DEPENDENCY include/ufeapi/ufeapi.proto
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/include/ufeapi)
add_library(ufeedclient SHARED
include/ufecpp/ufecppversion.h
include/ufecpp/ufecppdll.h
include/ufecpp/ufeedclient.hpp
src/ufeedclient/ufeedclient.cpp
${CMAKE_BINARY_DIR}/include/ufecpp/ufeapi.pb.cc ${CMAKE_BINARY_DIR}/include/ufecpp/ufeapi.pb.h
include/ufecpp/ufemessage.hpp
include/ufecpp/ufeconsts.hpp
include/ufecpp/ufeconfiguration.hpp
include/ufecpp/ufeexception.hpp
include/ufecpp/ufe_cpp_fields_fix40.hpp
include/ufecpp/ufe_cpp_fields_fix41.hpp
include/ufecpp/ufe_cpp_fields_fix42.hpp
include/ufecpp/ufe_cpp_fields_fix43.hpp
include/ufecpp/ufe_cpp_fields_fix44.hpp
include/ufecpp/ufe_cpp_fields_fix50.hpp
include/ufecpp/ufe_cpp_fields_fix50sp1.hpp
include/ufecpp/ufe_cpp_fields_fix50sp2.hpp
include/ufecpp/deprecated/ufeapi.hpp
)
target_include_directories(ufeedclient PRIVATE
${protobuf_include}
${zmq_include}
${cppzmq_include}
)
target_link_libraries(ufeedclient
PRIVATE
$<BUILD_INTERFACE:libzmq-static>
PUBLIC
libprotobuf-lite
)
find_version(ver sover)
target_link_set_version(ufeedclient ${sover})
add_executable(genconsts src/genconsts/genconsts.cpp)
target_include_directories(genconsts PRIVATE 3rdparty/cxxopts/include)
# deprecated
# tests
enable_testing()
add_executable(ufeedclient_test src/test/ufeedclient_test.cpp)
target_include_directories(ufeedclient_test PRIVATE
${protobuf_include}
${zmq_include}
${cppzmq_include}
)
target_link_libraries(ufeedclient_test PRIVATE
$<BUILD_INTERFACE:gtest_main>
PUBLIC
ufeedclient
uuid
)
add_test(NAME ufeedclient_test COMMAND ${CMAKE_COMMAND} -E env $<TARGET_FILE:ufeedclient_test>)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/.install" CACHE PATH "install path" FORCE)
endif()
message("-- installing to ${CMAKE_INSTALL_PREFIX}")
install(TARGETS ufeedclient RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static)
install(TARGETS libprotobuf-lite RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static)
install(DIRECTORY include/ufecpp DESTINATION include FILES_MATCHING PATTERN *.h PATTERN *.hpp)
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/ufecpp DESTINATION include FILES_MATCHING PATTERN *.h PATTERN *.hpp)
install(DIRECTORY 3rdparty/protobuf/src/google/protobuf/ DESTINATION include/google/protobuf/ FILES_MATCHING PATTERN *.h PATTERN *.inc)
install(FILES src/samples/CMakeLists.txt DESTINATION samples/)
install(FILES src/samples/sample0.cpp DESTINATION samples/)