2 find_package(BISON 2.3)
4 if("${BISON_VERSION}" VERSION_GREATER_EQUAL 3.0)
5 set(BISON_WARNINGS -Wno-deprecated)
8 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/csl)
9 bison_target(CSL_PARSER csl/parser.yy ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.cc
10 DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/parser.h
11 COMPILE_FLAGS ${BISON_WARNINGS}
13 set_source_files_properties(${BISON_CSL_PARSER_OUTPUTS} PROPERTIES
14 SKIP_UNITY_BUILD_INCLUSION ON)
16 set(FLEX_FLAGS --nounistd)
18 flex_target(CSL_SCANNER csl/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.cc
19 DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.h
20 COMPILE_FLAGS "${FLEX_FLAGS}"
22 set_source_files_properties(${FLEX_CSL_SCANNER_OUTPUTS} PROPERTIES
23 SKIP_UNITY_BUILD_INCLUSION ON)
24 add_flex_bison_dependency(CSL_SCANNER CSL_PARSER)
26 set(libmemcached_sources
28 ${FLEX_CSL_SCANNER_OUTPUTS}
29 ${BISON_CSL_PARSER_OUTPUTS}
78 check_cxx_compiler_flag(-Wno-deprecated-register W_NO_DEPRECATED_REGISTER)
80 if(W_NO_DEPRECATED_REGISTER)
81 set_source_files_properties(
82 ${FLEX_CSL_SCANNER_OUTPUTS}
83 ${BISON_CSL_PARSER_OUTPUTS}
84 PROPERTIES COMPILE_OPTIONS -Wno-deprecated-register
88 add_library(libmemcached SHARED)
89 add_library(memcached ALIAS libmemcached)
90 set_target_properties(libmemcached PROPERTIES
91 CXX_STANDARD ${CXX_STANDARD}
92 LIBRARY_OUTPUT_NAME memcached
93 LIBRARY_OUTPUT_NAME_DEBUG memcached-dbg
94 SOVERSION ${LIBMEMCACHED_SO_SOVERSION}
95 VERSION ${LIBMEMCACHED_SO_VERSION})
96 target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
97 target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${CMAKE_DL_LIBS})
98 target_link_libraries(libmemcached PRIVATE p9y)
100 target_link_libraries(libmemcached PUBLIC wsock32 ws2_32)
103 target_link_libraries(libmemcached PUBLIC ${BACKTRACE})
106 target_link_libraries(libmemcached PUBLIC ${LIBSASL})
108 if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
109 # see https://docs.oracle.com/cd/E77782_01/html/E77789/bkamq.html#OSSCPgrxeu
110 target_link_libraries(libmemcached INTERFACE stdc++ gcc_s CrunG3 c)
112 target_include_directories(libmemcached PRIVATE
113 ${CMAKE_SOURCE_DIR}/src
114 ${CMAKE_BINARY_DIR}/src
116 target_include_directories(libmemcached PUBLIC
117 $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
118 $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
119 $<INSTALL_INTERFACE:include>)
121 enable_dtrace_for(libmemcached libmemcached_probes.d dtrace_probes.h)
123 install(TARGETS libmemcached EXPORT libmemcached-targets
124 RUNTIME COMPONENT bin DESTINATION ${CMAKE_INSTALL_BINDIR}
125 ARCHIVE COMPONENT lib DESTINATION ${CMAKE_INSTALL_LIBDIR}
126 LIBRARY COMPONENT lib DESTINATION ${CMAKE_INSTALL_LIBDIR}
127 ${TARGET_NAMELINK_COMPONENT}
129 export(EXPORT libmemcached-targets NAMESPACE libmemcached::)
130 install(EXPORT libmemcached-targets NAMESPACE libmemcached::
132 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
134 install_public_headers(
142 target_sources(libmemcached PRIVATE
143 ${libmemcached_sources}
144 ${libmemcached_includes})
146 # TODO: do we really need this?
148 add_library(libmemcachedinternal STATIC)
149 add_library(memcachedinternal ALIAS libmemcachedinternal)
150 set_target_properties(libmemcachedinternal PROPERTIES CXX_STANDARD ${CXX_STANDARD} LIBRARY_OUTPUT_NAME memcachedinternal)
151 target_compile_definitions(libmemcachedinternal PRIVATE -DBUILDING_LIBMEMCACHEDINTERNAL)
152 target_link_libraries(libmemcachedinternal PUBLIC libhashkit Threads::Threads ${CMAKE_DL_LIBS})
153 target_link_libraries(libmemcachedinternal PRIVATE p9y)
155 target_link_libraries(libmemcached PUBLIC wsock32 ws2_32)
158 target_link_libraries(libmemcachedinternal PUBLIC ${LIBSASL})
161 target_link_libraries(libmemcachedinternal PUBLIC ${BACKTRACE})
163 target_include_directories(libmemcachedinternal PRIVATE
164 ${CMAKE_SOURCE_DIR}/src
165 ${CMAKE_BINARY_DIR}/src
167 target_include_directories(libmemcachedinternal PUBLIC
168 $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
169 $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
170 $<INSTALL_INTERFACE:include>)
172 enable_dtrace_for(libmemcachedinternal libmemcached_probes.d dtrace_probes.h)
174 # let libmemcached depend on libmemcachedinternal to ensure that they do not
175 # compete for the same generated dependencies
176 add_dependencies(libmemcached libmemcachedinternal)
178 target_sources(libmemcachedinternal PRIVATE
179 ${libmemcached_sources}
180 ${libmemcached_includes})