ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

760 lines
20 KiB

  1. #
  2. # Copyright (c) 2010 Artyom Beilis (Tonkikh)
  3. #
  4. # Distributed under the Boost Software License, Version 1.0. (See
  5. # accompanying file LICENSE_1_0.txt or copy at
  6. # http://www.boost.org/LICENSE_1_0.txt)
  7. #
  8. cmake_minimum_required(VERSION 2.6)
  9. project(booster)
  10. include(CheckFunctionExists)
  11. include(CheckCXXSourceCompiles)
  12. include(CheckLibraryExists)
  13. enable_testing()
  14. #
  15. # Most important includes
  16. #
  17. include_directories(${CMAKE_BINARY_DIR})
  18. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  19. include_directories(.)
  20. include_directories(lib/test)
  21. if(WIN32 OR CYGWIN)
  22. set(IS_WINDOWS TRUE)
  23. else()
  24. set(IS_WINDOWS FALSE)
  25. endif()
  26. if(WIN32 AND NOT CYGWIN)
  27. set(WINDOWS_NATIVE TRUE)
  28. else()
  29. set(WINDOWS_NATIVE FALSE)
  30. endif()
  31. if(CYGWIN)
  32. set(IS_CYGWIN TRUE)
  33. else()
  34. set(IS_CYGWIN FALSE)
  35. endif()
  36. # Options
  37. if(NOT LIBDIR)
  38. set(LIBDIR lib CACHE STRING "Library installation directory" FORCE)
  39. endif()
  40. option(USE_STLPORT "Build with STLPort library" OFF)
  41. option(USE_LIBCXX "Build with CXX library" OFF)
  42. option(USE_PTHREAD "Use pthreads API on windows" OFF)
  43. option(DISABLE_SHARED "Disable shared libraries build" OFF)
  44. option(DISABLE_STATIC "Disable static libraries build" OFF)
  45. option(DISABLE_ICU_LOCALE "Disable icu locale backend" OFF)
  46. if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
  47. option(DISABLE_STD_LOCALE "Disable std locale backend" ON)
  48. else()
  49. option(DISABLE_STD_LOCALE "Disable std locale backend" OFF)
  50. endif()
  51. option(USE_WINDOWS6_API "Use Windows 6 API (Vista, 7)" ON)
  52. check_function_exists(newlocale BOOSTER_HAS_XLOCALE)
  53. if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
  54. set(ENABLE_POSIX_LOCALE ON)
  55. elseif(APPLE)
  56. set(ENABLE_POSIX_LOCALE ON)
  57. elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD")
  58. if(BOOSTER_HAS_XLOCALE)
  59. set(ENABLE_POSIX_LOCALE ON)
  60. endif()
  61. else()
  62. set(ENABLE_POSIX_LOCALE OFF)
  63. endif()
  64. if(ENABLE_POSIX_LOCALE)
  65. option(DISABLE_POSIX_LOCALE "Disable POSIX locale backend" OFF)
  66. else()
  67. option(DISABLE_POSIX_LOCALE "Disable POSIX locale backend" ON)
  68. endif()
  69. if(IS_WINDOWS)
  70. option(DISABLE_WINAPI_LOCALE "Disable Win32API locale backend" OFF)
  71. else()
  72. option(DISABLE_WINAPI_LOCALE "Disable Win32API locale backend" ON)
  73. endif()
  74. if(WINDOWS_NATIVE)
  75. option(DISABLE_ICONV "Disable iconv library (default On on Windows)" ON)
  76. else()
  77. if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  78. option(DISABLE_ICONV "Disable iconv library (default On on Windows)" ON)
  79. else()
  80. option(DISABLE_ICONV "Disable iconv library (default On on Windows)" OFF)
  81. endif()
  82. endif()
  83. if(USE_LIBCXX)
  84. find_path(STLPORT_INCLUDE iostream)
  85. find_library(STLPORT_LIB c++)
  86. if(NOT STLPORT_INCLUDE OR NOT STLPORT_LIB)
  87. message(FATAL_ERROR "Can't find stlport include or library")
  88. else()
  89. include_directories(${STLPORT_INCLUDE})
  90. endif()
  91. endif()
  92. if(USE_STLPORT)
  93. find_path(STLPORT_INCLUDE stlport/iostream)
  94. find_library(STLPORT_LIB stlport)
  95. if(NOT STLPORT_INCLUDE OR NOT STLPORT_LIB)
  96. message(FATAL_ERROR "Can't find stlport include or library")
  97. else()
  98. include_directories(${STLPORT_INCLUDE}/stlport)
  99. endif()
  100. endif()
  101. # Fixing options if libraries are not found
  102. if(NOT DISABLE_ICU_LOCALE)
  103. message("-- Looking for ICU libraries")
  104. if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  105. if(MSVC)
  106. set(ICU_SUFFIX "d")
  107. endif()
  108. endif()
  109. find_library(ICU_UC icuuc${ICU_SUFFIX})
  110. find_library(ICU_DATA NAMES icudt${ICU_SUFFIX} icudata)
  111. find_library(ICU_I18N NAMES icuin${ICU_SUFFIX} icui18n${ICU_SUFFIX})
  112. find_path(ICU_INCLUDE_DIR unicode/unistr.h)
  113. if(ICU_UC AND ICU_DATA AND ICU_I18N AND ICU_INCLUDE_DIR)
  114. message("-- ICU Found, building booster locale")
  115. include_directories(${ICU_INCLUDE_DIR})
  116. else()
  117. message("-- ICU not found, disabling ICU localization backend")
  118. set(DISABLE_ICU_LOCALE ON)
  119. endif()
  120. endif()
  121. if(NOT DISABLE_ICU_LOCALE)
  122. add_definitions(-DBOOSTER_LOCALE_WITH_ICU)
  123. endif()
  124. # Checking for iconv
  125. if(NOT DISABLE_ICONV)
  126. check_cxx_source_compiles(
  127. "#include <iconv.h>
  128. int main() { iconv_t v=iconv_open((char *)0,(char *)0); }"
  129. LIBC_ICONV)
  130. if(NOT LIBC_ICONV)
  131. find_path(ICONV_INCLUDE_DIR iconv.h)
  132. find_library(ICONV_LIB iconv)
  133. if(ICONV_LIB AND ICONV_INCLUDE_DIR)
  134. set(BOOSTER_LOCALE_HAVE_ICONV 1)
  135. include_directories(${ICONV_INCLUDE_DIR})
  136. endif()
  137. else()
  138. set(BOOSTER_LOCALE_HAVE_ICONV 1)
  139. endif()
  140. if(BOOSTER_LOCALE_HAVE_ICONV)
  141. add_definitions(-DBOOSTER_LOCALE_WITH_ICONV)
  142. else()
  143. add_definitions(-DBOOSTER_LOCALE_NO_ICONV)
  144. endif()
  145. else()
  146. add_definitions(-DBOOSTER_LOCALE_NO_ICONV)
  147. endif(NOT DISABLE_ICONV)
  148. if(DISABLE_STD_LOCALE)
  149. add_definitions(-DBOOSTER_LOCALE_NO_STD_BACKEND)
  150. endif()
  151. if(DISABLE_POSIX_LOCALE)
  152. add_definitions(-DBOOSTER_LOCALE_NO_POSIX_BACKEND)
  153. endif()
  154. if(DISABLE_WINAPI_LOCALE)
  155. add_definitions(-DBOOSTER_LOCALE_NO_WINAPI_BACKEND)
  156. endif()
  157. #############################################################################
  158. #
  159. # Setup various build flags for different supported compilers and systems
  160. #
  161. #############################################################################
  162. if(CMAKE_COMPILER_IS_GNUCXX)
  163. check_cxx_source_compiles(
  164. "#if __GNUC__ < 4
  165. #error
  166. #endif
  167. int main() {}"
  168. GCC_IS_GCC4)
  169. set(CXX_FLAGS "-Wall -Wextra")
  170. if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  171. set(CXX_FLAGS "${CXX_FLAGS} -pthreads")
  172. endif()
  173. if(NOT GCC_IS_GCC4)
  174. # Uninitalized checks are bogous under gcc-3.4
  175. set(CXX_FLAGS "${CXX_FLAGS} -Wno-uninitialized")
  176. endif()
  177. if(IS_WINDOWS)
  178. if(GCC_IS_GCC4)
  179. # Very important, otherwise process would not start under cygwin
  180. set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--enable-auto-import")
  181. else()
  182. # gcc-3 does not have shared library for libstdc++ -- cause dll faitures with locale
  183. set(DISABLE_SHARED ON)
  184. endif()
  185. endif()
  186. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
  187. set(CXX_FLAGS "-Wall")
  188. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  189. set(CXX_FLAGS "-Wall -Wextra")
  190. elseif(MSVC)
  191. set(CXX_FLAGS "/EHsc /W3")
  192. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
  193. #
  194. # We use STL port under Sun Studio, standard library is broken
  195. #
  196. set(CXX_FLAGS "-library=stlport4 -xannotate=no")
  197. if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  198. set(CXX_FLAGS "${CXX_FLAGS} -mt")
  199. endif()
  200. endif()
  201. if(NOT IS_WINDOWS)
  202. check_function_exists(dlopen BOOSTER_HAVE_DLOPEN)
  203. if(NOT BOOSTER_HAVE_DLOPEN)
  204. find_library(BOOSTER_LIB_DL dl)
  205. endif()
  206. endif()
  207. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS}")
  208. #############################################################################
  209. #
  210. # Set default RelWithDebInfo build
  211. #
  212. #############################################################################
  213. if(NOT CMAKE_BUILD_TYPE)
  214. set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
  215. "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
  216. FORCE)
  217. endif(NOT CMAKE_BUILD_TYPE)
  218. if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  219. if(MSVC)
  220. set(ICU_SUFFIX "d")
  221. set(PCRE_SUFFIX "d")
  222. if(NOT BOOSTER_SUFFIX)
  223. set(BOOSTER_SUFFIX "-d")
  224. else()
  225. set(BOOSTER_SUFFIX "${BOOSTER_SUFFIX}d")
  226. endif()
  227. endif()
  228. endif()
  229. if(IS_WINDOWS)
  230. set(WS2_32 ws2_32)
  231. else()
  232. check_function_exists(socket HAVE_SOCKET)
  233. if(NOT HAVE_SOCKET)
  234. check_library_exists(socket socket "" HAVE_LIB_SOCKET)
  235. if(NOT HAVE_LIB_SOCKET)
  236. message(FATAL " No library with socket found")
  237. else(NOT HAVE_LIB_SOCKET)
  238. find_library(LIB_SOCKET socket)
  239. endif(NOT HAVE_LIB_SOCKET)
  240. endif(NOT HAVE_SOCKET)
  241. check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
  242. if(NOT HAVE_GETHOSTBYNAME)
  243. check_library_exists(socket gethostbyname "" LIB_SOCKGETHOSTBYNAME)
  244. if(NOT LIB_SOCKGETHOSTBYNAME)
  245. check_library_exists(nsl gethostbyname "" HAVE_LIB_NSL)
  246. if(NOT HAVE_LIB_NSL)
  247. message(FATAL " No library with gethostbyname found")
  248. else(NOT HAVE_LIB_NSL)
  249. find_library(LIB_NSL nsl)
  250. endif(NOT HAVE_LIB_NSL)
  251. endif(NOT LIB_SOCKGETHOSTBYNAME)
  252. endif(NOT HAVE_GETHOSTBYNAME)
  253. endif()
  254. check_cxx_source_compiles(
  255. "int main() { volatile int v=0; return __sync_bool_compare_and_swap(&v,0,1); }"
  256. BOOSTER_HAS_GCC_SYNC)
  257. check_cxx_source_compiles(
  258. "#include <bits/atomicity.h>
  259. using __gnu_cxx::__exchange_and_add;
  260. int main(){ volatile int x=0; return __exchange_and_add(&x,1);}"
  261. BOOSTER_HAVE_GCC_BITS_EXCHANGE_AND_ADD)
  262. check_cxx_source_compiles(
  263. "#include <ext/atomicity.h>
  264. using __gnu_cxx::__exchange_and_add;
  265. int main(){ volatile int x=0; return __exchange_and_add(&x,1);}"
  266. BOOSTER_HAVE_GCC_EXT_EXCHANGE_AND_ADD)
  267. check_cxx_source_compiles(
  268. "#include <sys/types.h>
  269. #include <machine/atomic.h>
  270. int main() { volatile unsigned v=0; return atomic_cmpset_int(&v,1,0); }"
  271. BOOSTER_HAVE_FREEBSD_ATOMIC)
  272. check_cxx_source_compiles(
  273. "#include <execinfo.h>
  274. int main() { backtrace(0,0); }"
  275. BOOSTER_HAVE_EXECINFO)
  276. check_cxx_source_compiles(
  277. "#include <stdexcept>
  278. #include <iostream>
  279. #include <stdlib.h>
  280. #include <string.h>
  281. #include <sstream>
  282. #include <typeinfo>
  283. #include <new>
  284. #ifdef __GNUC__
  285. #include <cxxabi.h>
  286. #endif
  287. extern \"C\" {
  288. extern void* _Unwind_GetIP (void *);
  289. extern int _Unwind_Backtrace(int (*)(void *,void *),void *);
  290. }
  291. int main() { _Unwind_Backtrace(0,0); _Unwind_GetIP(0); }"
  292. BOOSTER_HAVE_UNWIND_BACKTRACE)
  293. check_cxx_source_compiles(
  294. "#include <stdexcept>
  295. #include <iostream>
  296. #include <stdlib.h>
  297. #include <string.h>
  298. #include <sstream>
  299. #include <typeinfo>
  300. #include <new>
  301. #ifdef __GNUC__
  302. #include <cxxabi.h>
  303. #endif
  304. extern \"C\" {
  305. extern int _Unwind_Backtrace(int (*)(void *,void *),void *);
  306. }
  307. int main() { _Unwind_Backtrace(0,0); _Unwind_GetIP((_Unwind_Context *)0); }"
  308. BOOSTER_HAVE_UNWIND_BACKTRACE_BUILTIN)
  309. Check_cxx_source_compiles(
  310. "#include <atomic.h>
  311. int main() { volatile unsigned v=0; return atomic_add_int_nv(&v,1); }"
  312. BOOSTER_HAVE_SOLARIS_ATOMIC)
  313. check_cxx_source_compiles(
  314. "#include <libkern/OSAtomic.h>
  315. int main() { int32_t v=0; return OSAtomicAdd32(1,&v); }"
  316. BOOSTER_HAVE_MAC_OS_X_ATOMIC)
  317. check_cxx_source_compiles(
  318. "#include <stdint.h>
  319. int main() { int64_t x=10; return 0; }"
  320. BOOSTER_HAVE_STDINT_H)
  321. check_cxx_source_compiles(
  322. "#include <inttypes.h>
  323. int main() { int64_t x=10; return 0; }"
  324. BOOSTER_HAVE_INTTYPES_H)
  325. if(IS_WINDOWS)
  326. set(CMAKE_REQUIRED_LIBRARIES ${WS2_32})
  327. check_cxx_source_compiles(
  328. "#include <ws2tcpip.h>
  329. #include <winsock2.h>
  330. #include <windows.h>
  331. int main()
  332. { struct sockaddr_in6 in6; struct in6_addr in6addr; ::inet_pton(AF_INET6,\"::1\",&in6addr); return 0; }"
  333. BOOSTER_AIO_HAVE_PF_INET6)
  334. else()
  335. set(CMAKE_REQUIRED_LIBRARIES ${LIB_SOCKGETHOSTBYNAME} ${LIB_SOCKET} ${LIB_NSL})
  336. check_cxx_source_compiles(
  337. "#include <arpa/inet.h>
  338. #include <sys/socket.h>
  339. #include <sys/un.h>
  340. #include <netinet/in.h>
  341. int main()
  342. { struct sockaddr_in6 in6; struct in6_addr in6addr; ::inet_pton(AF_INET6,\"::1\",&in6addr); return 0; }"
  343. BOOSTER_AIO_HAVE_PF_INET6)
  344. endif()
  345. set(BOOSTER_SRC
  346. lib/ptime/src/posix_time.cpp
  347. lib/ptime/src/ctime.cpp
  348. lib/regex/src/pcre_regex.cpp
  349. lib/system/src/posix_error.cpp
  350. lib/system/src/windows_error.cpp
  351. lib/aio/src/aio_category.cpp
  352. lib/aio/src/deadline_timer.cpp
  353. lib/aio/src/endpoint.cpp
  354. lib/aio/src/io_service.cpp
  355. lib/aio/src/reactor.cpp
  356. lib/aio/src/select_iterrupter.cpp
  357. lib/aio/src/basic_io_device.cpp
  358. lib/aio/src/basic_socket.cpp
  359. lib/aio/src/acceptor.cpp
  360. lib/aio/src/stream_socket.cpp
  361. lib/smart_ptr/src/sp_counted_base.cpp
  362. lib/smart_ptr/src/atomic_counter.cpp
  363. lib/shared_object/src/shared_object.cpp
  364. lib/log/src/log.cpp
  365. lib/iostreams/src/streambuf.cpp
  366. lib/nowide/src/convert.cpp
  367. lib/backtrace/src/backtrace.cpp
  368. lib/locale/src/encoding/codepage.cpp
  369. lib/locale/src/shared/date_time.cpp
  370. lib/locale/src/shared/format.cpp
  371. lib/locale/src/shared/formatting.cpp
  372. lib/locale/src/shared/generator.cpp
  373. lib/locale/src/shared/ids.cpp
  374. lib/locale/src/shared/localization_backend.cpp
  375. lib/locale/src/shared/message.cpp
  376. lib/locale/src/shared/mo_lambda.cpp
  377. lib/locale/src/util/codecvt_converter.cpp
  378. lib/locale/src/util/default_locale.cpp
  379. lib/locale/src/util/info.cpp
  380. lib/locale/src/util/locale_data.cpp
  381. )
  382. if(NOT DISABLE_ICU_LOCALE)
  383. set(BOOSTER_SRC ${BOOSTER_SRC}
  384. lib/locale/src/icu/boundary.cpp
  385. lib/locale/src/icu/codecvt.cpp
  386. lib/locale/src/icu/collator.cpp
  387. lib/locale/src/icu/conversion.cpp
  388. lib/locale/src/icu/date_time.cpp
  389. lib/locale/src/icu/formatter.cpp
  390. lib/locale/src/icu/icu_backend.cpp
  391. lib/locale/src/icu/numeric.cpp
  392. lib/locale/src/icu/time_zone.cpp
  393. )
  394. endif()
  395. if(NOT DISABLE_POSIX_LOCALE)
  396. set(BOOSTER_SRC ${BOOSTER_SRC}
  397. lib/locale/src/posix/codecvt.cpp
  398. lib/locale/src/posix/collate.cpp
  399. lib/locale/src/posix/converter.cpp
  400. lib/locale/src/posix/numeric.cpp
  401. lib/locale/src/posix/posix_backend.cpp
  402. )
  403. endif()
  404. if(NOT DISABLE_WINAPI_LOCALE)
  405. set(BOOSTER_SRC ${BOOSTER_SRC}
  406. lib/locale/src/win32/collate.cpp
  407. lib/locale/src/win32/converter.cpp
  408. lib/locale/src/win32/lcid.cpp
  409. lib/locale/src/win32/numeric.cpp
  410. lib/locale/src/win32/win_backend.cpp
  411. )
  412. endif()
  413. if(NOT DISABLE_STD_LOCALE)
  414. set(BOOSTER_SRC ${BOOSTER_SRC}
  415. lib/locale/src/std/codecvt.cpp
  416. lib/locale/src/std/collate.cpp
  417. lib/locale/src/std/converter.cpp
  418. lib/locale/src/std/numeric.cpp
  419. lib/locale/src/std/std_backend.cpp
  420. )
  421. endif()
  422. if(NOT DISABLE_WINAPI_LOCALE OR NOT DISABLE_STD_LOCALE OR NOT DISABLE_POSIX_LOCALE)
  423. set(BOOSTER_SRC ${BOOSTER_SRC}
  424. lib/locale/src/util/gregorian.cpp)
  425. endif()
  426. if(USE_WINDOWS6_API)
  427. check_cxx_source_compiles(
  428. "
  429. #ifndef _WIN32_WINNT
  430. #define _WIN32_WINNT 0x600
  431. #endif
  432. #include <windows.h>
  433. int main(){ SRWLOCK l; InitializeSRWLock(&l); }"
  434. HAVE_WINDOWS6_API
  435. )
  436. endif()
  437. if(USE_WINDOWS6_API AND HAVE_WINDOWS6_API)
  438. set(BOOSTER_SRC ${BOOSTER_SRC}
  439. lib/thread/src/thread_winapi.cpp
  440. lib/thread/src/thread_win6.cpp)
  441. elseif(WINDOWS_NATIVE AND NOT USE_PTHREAD)
  442. set(BOOSTER_SRC ${BOOSTER_SRC}
  443. lib/thread/src/thread_winapi.cpp
  444. lib/thread/src/thread_win5.cpp)
  445. else()
  446. find_path(PTHREAD_INC pthread.h)
  447. include_directories(${PTHREAD_INC})
  448. if(MSVC)
  449. find_library(LIB_PTHREAD pthreadVC2)
  450. else()
  451. find_library(LIB_PTHREAD NAMES pthread thr kse pthreadGC2)
  452. endif()
  453. set(BOOSTER_SRC ${BOOSTER_SRC} lib/thread/src/pthread.cpp)
  454. endif()
  455. find_path(PCRE_INCLUDE pcre.h)
  456. if(PCRE_INCLUDE)
  457. include_directories(${PCRE_INCLUDE})
  458. endif()
  459. if(NOT PCRE_INCLUDE)
  460. find_path(PCRE_INCLUDE2 pcre/pcre.h)
  461. include_directories(${PCRE_INCLUDE2}/pcre)
  462. if(NOT PCRE_INCLUDE2)
  463. message(FATAL_ERROR "Can't find PCRE include directory")
  464. endif()
  465. endif()
  466. find_library(PCRE_LIB NAMES pcre${PCRE_SUFFIX} pcre)
  467. if(NOT PCRE_LIB)
  468. message(FATAL_ERROR "Can't find PCRE library")
  469. endif()
  470. set(LINK_LIBS )
  471. if(NOT DISABLE_SHARED)
  472. add_library(booster SHARED ${BOOSTER_SRC})
  473. set(LINK_LIBS ${LINK_LIBS} booster)
  474. if(IS_WINDOWS)
  475. set(BOOSTER_SHARED_DEFS ${BOOSTER_SHARED_DEFS} DLL_EXPORT)
  476. endif()
  477. set_target_properties(booster PROPERTIES COMPILE_DEFINITIONS "${BOOSTER_SHARED_DEFS}")
  478. set_target_properties(booster PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  479. set_target_properties(booster PROPERTIES OUTPUT_NAME "booster${BOOSTER_SUFFIX}")
  480. endif(NOT DISABLE_SHARED)
  481. if(NOT DISABLE_STATIC)
  482. add_library(booster-static STATIC ${BOOSTER_SRC})
  483. set(LINK_LIBS ${LINK_LIBS} booster-static)
  484. set_target_properties(booster-static PROPERTIES COMPILE_DEFINITIONS "${BOOST_STATIC_DEFS}")
  485. set_target_properties(booster-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  486. set_target_properties(booster-static PROPERTIES OUTPUT_NAME "booster${BOOSTER_SUFFIX}")
  487. endif(NOT DISABLE_STATIC)
  488. install(DIRECTORY booster DESTINATION include
  489. PATTERN ".svn" EXCLUDE)
  490. foreach(ALIB ${LINK_LIBS})
  491. if(LIB_SOCKGETHOSTBYNAME)
  492. target_link_libraries(${ALIB} ${LIB_SOCKGETHOSTBYNAME})
  493. endif(LIB_SOCKGETHOSTBYNAME)
  494. if(LIB_NSL)
  495. target_link_libraries(${ALIB} ${LIB_NSL})
  496. endif(LIB_NSL)
  497. if(LIB_SOCKET)
  498. target_link_libraries(${ALIB} ${LIB_SOCKET})
  499. endif(LIB_SOCKET)
  500. if(LIB_PTHREAD)
  501. target_link_libraries(${ALIB} ${LIB_PTHREAD})
  502. endif(LIB_PTHREAD)
  503. if(WS2_32)
  504. target_link_libraries(${ALIB} ${WS2_32})
  505. endif()
  506. target_link_libraries(${ALIB} ${PCRE_LIB})
  507. if(NOT DISABLE_ICU_LOCALE)
  508. target_link_libraries(${ALIB} ${ICU_UC})
  509. target_link_libraries(${ALIB} ${ICU_I18N})
  510. target_link_libraries(${ALIB} ${ICU_DATA})
  511. endif()
  512. if(BOOSTER_LIB_DL)
  513. target_link_libraries(${ALIB} ${BOOSTER_LIB_DL})
  514. endif()
  515. if(ICONV_LIB)
  516. target_link_libraries(${ALIB} ${ICONV_LIB})
  517. endif()
  518. if(MSVC)
  519. target_link_libraries(${ALIB} dbghelp)
  520. endif()
  521. if(IS_WINDOWS)
  522. target_link_libraries(${ALIB} psapi)
  523. endif()
  524. if(STLPORT_LIB)
  525. target_link_libraries(${ALIB} ${STLPORT_LIB} supc++)
  526. endif()
  527. if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.6)
  528. set_target_properties(${ALIB} PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/booster/build_config.h")
  529. else()
  530. set_target_properties(${ALIB} PROPERTIES PUBLIC_HEADER "${CMAKE_BINARY_DIR}/booster/build_config.h")
  531. endif()
  532. if(IS_WINDOWS)
  533. set_target_properties(${ALIB} PROPERTIES VERSION ${BOOSTER_SOVERSION} SOVERSION ${BOOSTER_SOVERSION})
  534. else()
  535. set_target_properties(${ALIB} PROPERTIES VERSION ${BOOSTER_VERSION} SOVERSION ${BOOSTER_SOVERSION})
  536. endif()
  537. endforeach()
  538. if(MSVC AND NOT DISABLE_STATIC)
  539. set_target_properties(booster-static PROPERTIES PREFIX "lib")
  540. endif(MSVC AND NOT DISABLE_STATIC)
  541. set(EXE_COM_DEFS "")
  542. if(NOT DISABLE_SHARED)
  543. set(BOOSTER_LIB booster)
  544. if(IS_WINDOWS)
  545. set(EXE_COM_DEFS "${EXE_COM_DEFS}" "DLL_EXPORT")
  546. endif()
  547. else()
  548. set(BOOSTER_LIB booster-static)
  549. endif()
  550. macro(add_booster_param_test MODULE TEST PARAMETER)
  551. set(TEST_SRC "lib/${MODULE}/test/test_${TEST}.cpp")
  552. set(TEST_NAME "test_${MODULE}_${TEST}")
  553. add_executable(${TEST_NAME} ${TEST_SRC})
  554. target_link_libraries(${TEST_NAME} ${BOOSTER_LIB})
  555. set_target_properties(${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS "${EXE_COM_DEFS}")
  556. add_test(${TEST_NAME} ${TEST_NAME} ${PARAMETER})
  557. set_tests_properties(${TEST_NAME} PROPERTIES TIMEOUT 20)
  558. endmacro()
  559. macro(add_booster_test MODULE TEST)
  560. add_booster_param_test(${MODULE} ${TEST} "")
  561. endmacro()
  562. add_booster_test(function function)
  563. add_booster_test(function callback)
  564. add_booster_test(ptime posix_time)
  565. add_booster_test(thread thread)
  566. if(UNIX)
  567. add_booster_test(thread fork)
  568. endif()
  569. add_booster_test(smart_ptr shared_ptr)
  570. add_booster_test(smart_ptr atomic_counter)
  571. add_booster_test(smart_ptr sp_counter)
  572. add_booster_test(log log)
  573. add_booster_test(nowide nowide)
  574. add_booster_test(iostreams streambuf)
  575. add_booster_test(regex regex)
  576. add_booster_test(aio reactor)
  577. add_booster_test(aio timer)
  578. add_booster_test(aio event_loop)
  579. add_booster_test(aio socket)
  580. add_booster_test(aio endpoint)
  581. add_booster_test(backtrace backtrace)
  582. if(NOT IS_WINDOWS)
  583. add_booster_test(aio prefork)
  584. endif()
  585. add_booster_test(locale codepage)
  586. add_booster_param_test(locale message "${CMAKE_CURRENT_SOURCE_DIR}/lib/locale/test")
  587. add_booster_test(locale ios_prop)
  588. add_booster_test(locale codepage_converter)
  589. add_booster_test(locale date_time)
  590. add_booster_test(locale generator)
  591. add_booster_test(locale config)
  592. add_booster_test(locale utf)
  593. add_booster_test(locale codecvt)
  594. if(NOT DISABLE_ICU_LOCALE)
  595. add_booster_test(locale collate)
  596. add_booster_test(locale convert)
  597. add_booster_test(locale boundary)
  598. add_booster_test(locale formatting)
  599. add_booster_test(locale icu_vs_os_timezone)
  600. if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  601. set_target_properties(test_locale_formatting PROPERTIES COMPILE_FLAGS "-O0")
  602. endif()
  603. endif()
  604. if(NOT DISABLE_STD_LOCALE)
  605. add_booster_test(locale std_convert)
  606. add_booster_test(locale std_formatting)
  607. add_booster_test(locale std_collate)
  608. endif()
  609. if(NOT DISABLE_POSIX_LOCALE)
  610. add_booster_test(locale posix_collate)
  611. add_booster_test(locale posix_convert)
  612. add_booster_test(locale posix_formatting)
  613. endif()
  614. if(NOT DISABLE_WINAPI_LOCALE)
  615. add_booster_test(locale winapi_formatting)
  616. add_booster_test(locale winapi_collate)
  617. add_booster_test(locale winapi_convert)
  618. endif()
  619. set(BOOSTER_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
  620. set(BOOSTER_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
  621. configure_file(lib/booster_build_config.cmake.h booster/build_config.h)
  622. install(TARGETS ${LINK_LIBS}
  623. RUNTIME DESTINATION bin
  624. LIBRARY DESTINATION ${LIBDIR}
  625. ARCHIVE DESTINATION ${LIBDIR}
  626. PUBLIC_HEADER DESTINATION include/booster)