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.
 
 
 
 
 
 

725 lines
19 KiB

  1. cmake_minimum_required(VERSION 2.6)
  2. project(cppcms)
  3. set(PACKAGE_NAME "CppCMS")
  4. set(PACKAGE_STRING "CppCMS/0.99.1")
  5. set(PACKAGE_VERSION "0.99.1")
  6. include(CheckFunctionExists)
  7. include(CheckCXXSourceCompiles)
  8. include(CheckLibraryExists)
  9. include(CPack)
  10. enable_testing()
  11. #############################################################################
  12. #
  13. # Setup default build options
  14. #
  15. #############################################################################
  16. option(DISABLE_ICU_LOCALIZATION
  17. "Use standard std::locales instead of ICU" OFF)
  18. option(DISABLE_SHARED "Disable shared libraries build" OFF)
  19. option(DISABLE_STATIC "Disable static libraries build" OFF)
  20. option(DISABLE_ICONV "Disable usage iconv library - use ICU for conversion" OFF)
  21. option(DISABLE_GCRYPT "Disable usage of gcrypt library, no AES cookies encryption would be available" OFF)
  22. option(USE_EXTERNAL_BOOST "Use external Boost library and not internal one, boost version provided by BOOST_SUFFIX variable" OFF)
  23. option(DISABLE_FCGI "Disable fastcgi web server api" OFF)
  24. option(DISABLE_SCGI "Disable scgi web server api" OFF)
  25. option(DISABLE_HTTP "Disable http web server" OFF)
  26. if(DISABLE_ICU_LOCALIZATION OR USE_EXTERNAL_BOOST)
  27. set(CPPCMS_SUFFIX "-c")
  28. endif()
  29. if(DISABLE_ICU_LOCALIZATION)
  30. set(BOOSTER_NO_LOCALE ON)
  31. endif()
  32. add_subdirectory(booster)
  33. include_directories(booster)
  34. include_directories(src)
  35. include_directories(private)
  36. #############################################################################
  37. #
  38. # Setup various build flags for different supported compilers and systems
  39. #
  40. #############################################################################
  41. if(CMAKE_COMPILER_IS_GNUCXX)
  42. check_cxx_source_compiles(
  43. "#if __GNUC__ < 4
  44. #error
  45. #endif
  46. int main() {}"
  47. GCC_IS_GCC4)
  48. set(CXX_FLAGS "-Wall")
  49. if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  50. set(CXX_FLAGS "${CXX_FLAGS} -pthreads")
  51. endif()
  52. if(NOT GCC_IS_GCC4)
  53. # Uninitalized checks are bogous under gcc-3.4
  54. set(CXX_FLAGS "${CXX_FLAGS} -Wno-uninitialized")
  55. endif()
  56. if(WIN32)
  57. if(GCC_IS_GCC4)
  58. # Very important, otherwise process would not start under cygwin
  59. set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--enable-auto-import")
  60. else()
  61. # gcc-3 does not have shared library for libstdc++ -- cause dll faitures with locale
  62. set(DISABLE_SHARED ON)
  63. endif()
  64. endif()
  65. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
  66. set(CXX_FLAGS "-Wall")
  67. elseif(MSVC)
  68. set(CXX_FLAGS "/EHsc /W3")
  69. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
  70. #
  71. # We use STL port under Sun Studio, standard library is broken
  72. #
  73. set(CXX_FLAGS "-library=stlport4")
  74. if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  75. set(CXX_FLAGS "${CXX_FLAGS} -mt")
  76. endif()
  77. endif()
  78. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS}")
  79. #############################################################################
  80. #
  81. # Set default RelWithDebInfo build
  82. #
  83. #############################################################################
  84. if(NOT CMAKE_BUILD_TYPE)
  85. set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
  86. "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
  87. FORCE)
  88. endif(NOT CMAKE_BUILD_TYPE)
  89. if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
  90. if(MSVC)
  91. set(ICU_SUFFIX "d")
  92. if(NOT CPPCMS_SUFFIX)
  93. set(CPPCMS_SUFFIX "-d")
  94. else()
  95. set(CPPCMS_SUFFIX "${CPPCMS_SUFFIX}d")
  96. endif()
  97. endif()
  98. endif()
  99. if(USE_EXTERNAL_BOOST)
  100. set(CPPCMS_USE_EXTERNAL_BOOST 1)
  101. endif(USE_EXTERNAL_BOOST)
  102. if(NOT USE_EXTERNAL_BOOST)
  103. add_subdirectory(cppcms_boost)
  104. include_directories(cppcms_boost)
  105. else(NOT USE_EXTERNAL_BOOST)
  106. find_path(BOOST_INCLUDE_DIR boost/shared_ptr.hpp)
  107. find_library(BOOST_SYSTEM boost_system-${BOOST_SUFFIX} NAMES boost_system boost_system-mt)
  108. find_library(BOOST_FILESYSTEM boost_filesystem-${BOOST_SUFFIX} NAMES boost_filesystem boost_filesystem-mt)
  109. find_library(BOOST_IOSTREAMS boost_iostreams-${BOOST_SUFFIX} NAMES boost_iostreams boost_iostreams-mt)
  110. find_library(BOOST_ZLIB boost_zlib-${BOOST_SUFFIX} NAMES boost_zlib boost_zlib)
  111. include_directories(${BOOST_INCLUDE_DIR})
  112. endif(NOT USE_EXTERNAL_BOOST)
  113. if(NOT DISABLE_ICU_LOCALIZATION)
  114. find_library(ICU_UC icuuc${ICU_SUFFIX})
  115. find_library(ICU_DATA icudata NAMES icudt)
  116. find_library(ICU_I18N icui18n${ICU_SUFFIX} NAMES icuin${ICU_SUFFIX})
  117. find_path(ICU_INCLUDE_DIR unicode/unistr.h)
  118. if(NOT ICU_UC OR NOT ICU_DATA OR NOT ICU_I18N OR NOT ICU_INCLUDE_DIR)
  119. message(FATAL " Failed to find ICU library, can't continue")
  120. endif()
  121. set(HAVE_ICU 1)
  122. else()
  123. set(CPPCMS_DISABLE_ICU_LOCALIZATION 1)
  124. endif()
  125. find_path(HAVE_STDINT_H stdint.h)
  126. find_path(HAVE_INTTYPES_H inttypes.h)
  127. check_function_exists(atoll HAVE_ATOLL)
  128. check_function_exists(_atoi64 HAVE_ATOI64)
  129. check_function_exists(gmtime_r HAVE_GMTIME_R)
  130. check_function_exists(localtime_r HAVE_LOCALTIME_R)
  131. check_function_exists(strerror_r HAVE_STRERROR_R)
  132. check_function_exists(snprintf HAVE_SNPRINTF)
  133. check_function_exists(stat HAVE_STAT)
  134. check_function_exists(_stat HAVE__STAT)
  135. include_directories(${ICU_INCLUDE_DIR})
  136. if(NOT DISABLE_ICONV)
  137. check_cxx_source_compiles(
  138. "#include <iconv.h>
  139. int main() { iconv_t v=iconv_open((char *)0,(char *)0); }"
  140. LIBC_ICONV)
  141. if(NOT LIBC_ICONV)
  142. find_path(ICONV_INCLUDE_DIR iconv.h)
  143. find_library(ICONV_LIB iconv)
  144. if(ICONV_LIB AND ICONV_INCLUDE_DIR)
  145. set(HAVE_ICONV 1)
  146. include_directories(${ICONV_INCLUDE_DIR})
  147. endif()
  148. else(NOT LIBC_ICONV)
  149. set(HAVE_ICONV 1)
  150. endif(NOT LIBC_ICONV)
  151. if(NOT HAVE_ICONV)
  152. message(STATUS " iconv not found, falling back to ICU")
  153. endif(NOT HAVE_ICONV)
  154. endif(NOT DISABLE_ICONV)
  155. include_directories(${CMAKE_BINARY_DIR})
  156. include_directories(${CMAKE_SOURCE_DIR})
  157. if(DISABLE_ICU_LOCALIZATION)
  158. include_directories(noicu)
  159. else()
  160. include_directories(localization)
  161. endif()
  162. set(CPPCMS_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
  163. set(CPPCMS_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
  164. #
  165. # Atomic API tests
  166. #
  167. check_cxx_source_compiles(
  168. "#include <string>
  169. int main() { std::wstring s; }"
  170. HAVE_STD_WSTRING)
  171. check_cxx_source_compiles(
  172. "#include <time.h>
  173. int main() { struct tm t; char const *p=t.tm_zone; long o=t.tm_gmtoff; }"
  174. HAVE_BSD_TM)
  175. check_cxx_source_compiles(
  176. "#include <string>
  177. int main() { std::u16string s16; std::u32string s32; }"
  178. HAVE_CPP0X_UXSTRING)
  179. check_cxx_source_compiles(
  180. "#include <list>
  181. int main(){std::list<int> l; auto p=l.begin();}"
  182. HAVE_CPP_0X_AUTO)
  183. check_cxx_source_compiles(
  184. "#include <list>
  185. int main(){std::list<int> l; decltype(l.begin()) p=l.begin();}"
  186. HAVE_CPP_0X_DECLTYPE)
  187. check_cxx_source_compiles(
  188. "#include <list>
  189. int main(){std::list<int> l; typeof(l.begin()) p=l.begin();}"
  190. HAVE_GCC_TYPEOF)
  191. check_cxx_source_compiles(
  192. "#include <list>
  193. int main(){std::list<int> l; __typeof__(l.begin()) p=l.begin();}"
  194. HAVE_UNDERSCORE_TYPEOF)
  195. if(${CMAKE_HOST_WIN32})
  196. find_library(WS2_32 ws2_32)
  197. find_library(WSOCK32 wsock32)
  198. else(${CMAKE_HOST_WIN32})
  199. check_function_exists(dlopen HAVE_DLOPEN)
  200. if(NOT HAVE_DLOPEN)
  201. check_library_exists(dl dlopen "" HAVE_LIB_DL)
  202. if(NOT HAVE_LIB_DL)
  203. message(FATAL " No library with dlopen found")
  204. else(NOT HAVE_LIB_DL)
  205. find_library(LIB_DL dl)
  206. endif(NOT HAVE_LIB_DL)
  207. endif(NOT HAVE_DLOPEN)
  208. check_function_exists(socket HAVE_SOCKET)
  209. if(NOT HAVE_SOCKET)
  210. check_library_exists(socket socket "" HAVE_LIB_SOCKET)
  211. if(NOT HAVE_LIB_SOCKET)
  212. message(FATAL " No library with socket found")
  213. else(NOT HAVE_LIB_SOCKET)
  214. find_library(LIB_SOCKET socket)
  215. endif(NOT HAVE_LIB_SOCKET)
  216. endif(NOT HAVE_SOCKET)
  217. check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
  218. if(NOT HAVE_GETHOSTBYNAME)
  219. check_library_exists(socket gethostbyname "" LIB_SOCKGETHOSTBYNAME)
  220. if(NOT LIB_SOCKGETHOSTBYNAME)
  221. check_library_exists(nsl gethostbyname "" HAVE_LIB_NSL)
  222. if(NOT HAVE_LIB_NSL)
  223. message(FATAL " No library with gethostbyname found")
  224. else(NOT HAVE_LIB_NSL)
  225. find_library(LIB_NSL nsl)
  226. endif(NOT HAVE_LIB_NSL)
  227. endif(NOT LIB_SOCKGETHOSTBYNAME)
  228. endif(NOT HAVE_GETHOSTBYNAME)
  229. endif(${CMAKE_HOST_WIN32})
  230. check_function_exists(canonicalize_file_name HAVE_CANONICALIZE_FILE_NAME)
  231. if(USE_EXTERNAL_BOOST)
  232. if(WIN32)
  233. add_definitions(-DBOOST_ALL_NO_LIB)
  234. add_definitions(-DBOOST_REGEX_DYN_LINK)
  235. add_definitions(-DBOOST_FILESYSTEM_DYN_LINK)
  236. add_definitions(-DBOOST_SYSTEM_DYN_LINK)
  237. add_definitions(-DBOOST_IOSTREAMS_DYN_LINK)
  238. add_definitions(-DBOOST_THREAD_DYN_LINK)
  239. add_definitions(-DBOOST_DATE_TIME_DYN_LINK)
  240. add_definitions(-DBOOST_ZLIB_DYN_LINK)
  241. endif(WIN32)
  242. else(USE_EXTERNAL_BOOST)
  243. add_definitions(-DCPPCMS_BOOST_ALL_NO_LIB)
  244. if(NOT DISABLE_SHARED)
  245. add_definitions(-DCPPCMS_BOOST_ALL_DYN_LINK)
  246. endif(NOT DISABLE_SHARED)
  247. endif(USE_EXTERNAL_BOOST)
  248. set(CPPCMS_PUBLIC_HEADERS
  249. application.h
  250. applications_pool.h
  251. base64.h
  252. base_content.h
  253. base_view.h
  254. cache_interface.h
  255. cache_pool.h
  256. # connection_forwarder.h
  257. cppcms_error.h
  258. cstdint.h
  259. defs.h
  260. encoding.h
  261. filters.h
  262. form.h
  263. http_context.h
  264. http_cookie.h
  265. http_file.h
  266. http_request.h
  267. http_response.h
  268. intrusive_ptr.h
  269. json.h
  270. mem_bind.h
  271. noncopyable.h
  272. refcounted.h
  273. regex.h
  274. rpc_json.h
  275. service.h
  276. session_api.h
  277. session_cookies.h
  278. session_dual.h
  279. session_interface.h
  280. session_pool.h
  281. session_sid.h
  282. session_storage.h
  283. thread_pool.h
  284. urandom.h
  285. url_dispatcher.h
  286. util.h
  287. view.h
  288. views_pool.h
  289. ${CMAKE_CURRENT_BINARY_DIR}/config.h
  290. )
  291. set(CPPCMS_SOURCES
  292. src/service.cpp
  293. src/cgi_api.cpp
  294. src/http_request.cpp
  295. src/http_response.cpp
  296. src/http_context.cpp
  297. src/cppcms_error.cpp
  298. src/cppcms_error_category.cpp
  299. src/thread_pool.cpp
  300. src/applications_pool.cpp
  301. src/application.cpp
  302. src/url_dispatcher.cpp
  303. src/http_cookie.cpp
  304. src/util.cpp
  305. src/base64.cpp
  306. src/base_view.cpp
  307. src/views_pool.cpp
  308. src/internal_file_server.cpp
  309. src/json.cpp
  310. src/encoding.cpp
  311. src/form.cpp
  312. src/filters.cpp
  313. src/cache_pool.cpp
  314. src/cache_interface.cpp
  315. src/cache_storage.cpp
  316. src/tcp_cache_client.cpp
  317. src/cache_over_ip.cpp
  318. src/tcp_messenger.cpp
  319. src/tcp_connector.cpp
  320. src/tcp_cache_server.cpp
  321. src/connection_forwarder.cpp
  322. src/session_pool.cpp
  323. src/base_encryptor.cpp
  324. src/hmac_encryptor.cpp
  325. src/md5.cpp
  326. src/urandom.cpp
  327. src/session_cookies.cpp
  328. src/session_dual.cpp
  329. src/session_sid.cpp
  330. src/session_interface.cpp
  331. src/session_memory_storage.cpp
  332. src/rpc_json.cpp
  333. )
  334. if(DISABLE_ICU_LOCALIZATION)
  335. set(CPPCMS_SOURCES ${CPPCMS_SOURCES}
  336. noicu/src/locale_src_conversion.cpp
  337. noicu/src/locale_src_format.cpp
  338. noicu/src/locale_src_formatting.cpp
  339. noicu/src/locale_src_generator.cpp
  340. noicu/src/locale_src_info.cpp
  341. noicu/src/locale_src_message.cpp
  342. noicu/src/locale_src_mo_lambda.cpp
  343. noicu/src/locale_src_numeric.cpp)
  344. set(CPPCMS_PUBLIC_HEADERS ${CPPCMS_PUBLIC_HEADERS}
  345. noicu/locale_conversion.h
  346. noicu/locale_format.h
  347. noicu/locale_formatting.h
  348. noicu/locale_generator.h
  349. noicu/locale_info.h
  350. noicu/locale_message.h
  351. noicu/locale_numeric.h
  352. noicu/noicu_localization.h)
  353. endif(DISABLE_ICU_LOCALIZATION)
  354. if(NOT DISABLE_GCRYPT)
  355. find_path(GCRYPT_INCLUDE_DIR gcrypt.h)
  356. find_library(LIB_GCRYPT gcrypt)
  357. if(LIB_GCRYPT AND GCRYPT_INCLUDE_DIR)
  358. include_directories(${GCRYPT_INCLUDE_DIR})
  359. endif()
  360. endif(NOT DISABLE_GCRYPT)
  361. if(NOT DISABLE_FCGI)
  362. set(CPPCMS_SOURCES ${CPPCMS_SOURCES} src/fastcgi_api.cpp)
  363. set(CPPCMS_HAS_FCGI 1)
  364. endif()
  365. if(NOT DISABLE_SCGI)
  366. set(CPPCMS_SOURCES ${CPPCMS_SOURCES} src/scgi_api.cpp)
  367. set(CPPCMS_HAS_SCGI 1)
  368. endif()
  369. if(NOT DISABLE_HTTP)
  370. set(CPPCMS_SOURCES ${CPPCMS_SOURCES} src/http_api.cpp)
  371. set(CPPCMS_HAS_HTTP 1)
  372. endif()
  373. if(LIB_GCRYPT)
  374. set(CPPCMS_SOURCES ${CPPCMS_SOURCES} src/aes_encryptor.cpp)
  375. set(HAVE_GCRYPT 1)
  376. else(LIB_GCRYPT)
  377. message("GNU Gcrypt library not found, disabling aes_encryptor")
  378. endif(LIB_GCRYPT)
  379. if(WIN32 AND NOT CYGWIN)
  380. set(CPPCMS_SOURCES ${CPPCMS_SOURCES} src/session_win32_file_storage.cpp)
  381. else(WIN32 AND NOT CYGWIN)
  382. set(CPPCMS_SOURCES ${CPPCMS_SOURCES} src/session_posix_file_storage.cpp)
  383. endif(WIN32 AND NOT CYGWIN)
  384. if(NOT DISABLE_SHARED)
  385. add_library(cppcms SHARED ${CPPCMS_SOURCES})
  386. set(CPPCMS_LIB cppcms)
  387. else(NOT DISABLE_SHARED)
  388. set(CPPCMS_LIB cppcms-static)
  389. endif(NOT DISABLE_SHARED)
  390. if(NOT DISABLE_STATIC)
  391. add_library(cppcms-static STATIC ${CPPCMS_SOURCES})
  392. endif(NOT DISABLE_STATIC)
  393. if(DISABLE_SHARED OR DISABLE_STATIC)
  394. set(CPPCMS_LIBS ${CPPCMS_LIB})
  395. else(DISABLE_SHARED OR DISABLE_STATIC)
  396. set(CPPCMS_LIBS cppcms; cppcms-static)
  397. endif(DISABLE_SHARED OR DISABLE_STATIC)
  398. foreach(ALIB ${CPPCMS_LIBS})
  399. if(DISABLE_SHARED)
  400. target_link_libraries(${ALIB} booster-static)
  401. else(DISABLE_SHARED)
  402. target_link_libraries(${ALIB} booster)
  403. endif(DISABLE_SHARED)
  404. if(NOT USE_EXTERNAL_BOOST)
  405. if(DISABLE_SHARED)
  406. target_link_libraries(${ALIB} boost-static)
  407. else(DISABLE_SHARED)
  408. target_link_libraries(${ALIB} boost)
  409. endif(DISABLE_SHARED)
  410. else(NOT USE_EXTERNAL_BOOST)
  411. target_link_libraries(${ALIB} ${BOOST_REGEX})
  412. target_link_libraries(${ALIB} ${BOOST_IOSTREAMS})
  413. target_link_libraries(${ALIB} ${BOOST_DATE_TIME})
  414. target_link_libraries(${ALIB} ${BOOST_THREAD})
  415. target_link_libraries(${ALIB} ${BOOST_FILESYSTEM})
  416. target_link_libraries(${ALIB} ${BOOST_SYSTEM})
  417. if(BOOST_ZLIB)
  418. target_link_libraries(${ALIB} ${BOOST_ZLIB})
  419. endif(BOOST_ZLIB)
  420. endif(NOT USE_EXTERNAL_BOOST)
  421. if(LIB_GCRYPT)
  422. target_link_libraries(${ALIB} ${LIB_GCRYPT})
  423. endif(LIB_GCRYPT)
  424. if(ICONV_LIB)
  425. target_link_libraries(${ALIB} ${ICONV_LIB})
  426. endif(ICONV_LIB)
  427. if(WS2_32 AND WSOCK32)
  428. target_link_libraries(${ALIB} ${WS2_32})
  429. target_link_libraries(${ALIB} ${WSOCK32})
  430. endif(WS2_32 AND WSOCK32)
  431. if(LIB_SOCKGETHOSTBYNAME)
  432. target_link_libraries(${ALIB} ${LIB_SOCKGETHOSTBYNAME})
  433. endif(LIB_SOCKGETHOSTBYNAME)
  434. if(LIB_NSL)
  435. target_link_libraries(${ALIB} ${LIB_NSL})
  436. endif(LIB_NSL)
  437. if(LIB_SOCKET)
  438. target_link_libraries(${ALIB} ${LIB_SOCKET})
  439. endif(LIB_SOCKET)
  440. if(LIB_DL)
  441. target_link_libraries(${ALIB} ${LIB_DL})
  442. endif(LIB_DL)
  443. endforeach(ALIB)
  444. find_program(PYTHON python)
  445. if(NOT PYTHON)
  446. message(FATAL "Can't build without Python interpreter")
  447. endif(NOT PYTHON)
  448. # Templates builds
  449. add_custom_command(
  450. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/skin1.cpp
  451. COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc
  452. -s skin1
  453. -o ${CMAKE_CURRENT_BINARY_DIR}/skin1.cpp
  454. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_skin1.tmpl
  455. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_view1.tmpl
  456. DEPENDS
  457. ${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc
  458. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_skin1.tmpl
  459. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_view1.tmpl)
  460. add_custom_command(
  461. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/skin2.cpp
  462. COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc
  463. -s skin2
  464. -o ${CMAKE_CURRENT_BINARY_DIR}/skin2.cpp
  465. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_skin2.tmpl
  466. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_view1.tmpl
  467. DEPENDS
  468. ${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc
  469. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_skin2.tmpl
  470. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_view1.tmpl)
  471. if(NOT DISABLE_SHARED)
  472. add_custom_command(
  473. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/skin3.cpp
  474. COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc
  475. -s skin3
  476. -o ${CMAKE_CURRENT_BINARY_DIR}/skin3.cpp
  477. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_skin2.tmpl
  478. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_view1.tmpl
  479. DEPENDS
  480. ${CMAKE_CURRENT_SOURCE_DIR}/bin/cppcms_tmpl_cc
  481. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_skin2.tmpl
  482. ${CMAKE_CURRENT_SOURCE_DIR}/src/hello_world_view1.tmpl)
  483. add_library(skin3 MODULE skin3.cpp)
  484. set(SKIN3_DEFS CPPCMS_SKIN_MODULE DLL_EXPORT)
  485. set_target_properties(skin3 PROPERTIES
  486. COMPILE_DEFINITIONS "${SKIN3_DEFS}")
  487. target_link_libraries(skin3 ${CPPCMS_LIB})
  488. endif(NOT DISABLE_SHARED)
  489. add_executable(hello_world src/hello_world.cpp skin1.cpp skin2.cpp)
  490. target_link_libraries(hello_world ${CPPCMS_LIB})
  491. add_executable(cppcms_scale src/cache_server_main.cpp)
  492. target_link_libraries(cppcms_scale ${CPPCMS_LIB})
  493. add_executable(cppcms_config_find_param src/cppcms_config_find_param.cpp src/json.cpp)
  494. #########################################
  495. # Tests
  496. #########################################
  497. set(ALL_TESTS
  498. form_test
  499. proto_test
  500. encryptor_test
  501. storage_test
  502. cache_backend_test
  503. json_test
  504. base64_test
  505. forwarder_test
  506. jsonrpc_test
  507. )
  508. foreach(TEST ${ALL_TESTS})
  509. add_executable(${TEST} tests/${TEST}.cpp)
  510. target_link_libraries(${TEST} ${CPPCMS_LIB})
  511. endforeach()
  512. if(NOT DISABLE_ICU_LOCALIZATION)
  513. file(GLOB LOCALE_TEST_SOURCES "localization/locale_src_test_*.cpp")
  514. else()
  515. file(GLOB LOCALE_TEST_SOURCES "noicu/locale_src_test_*.cpp")
  516. endif()
  517. foreach(LFILE ${LOCALE_TEST_SOURCES})
  518. string(REGEX REPLACE ".*(localization|noicu)/(.*)\\.cpp" "\\2" TEST_NAME ${LFILE})
  519. add_executable(${TEST_NAME} ${LFILE})
  520. target_link_libraries(${TEST_NAME} ${CPPCMS_LIB})
  521. set(LOCALE_TESTS "${LOCALE_TESTS} ${TEST_NAME}")
  522. add_test(${TEST_NAME} ${TEST_NAME} "${CMAKE_CURRENT_SOURCE_DIR}/tests")
  523. endforeach()
  524. #####################################
  525. # End of tests
  526. #####################################
  527. # These are use export
  528. if(WIN32 AND NOT DISABLE_SHARED)
  529. set_target_properties(${ALL_TESTS} hello_world cppcms PROPERTIES
  530. COMPILE_DEFINITIONS DLL_EXPORT)
  531. endif(WIN32 AND NOT DISABLE_SHARED)
  532. set_target_properties(${CPPCMS_LIBS} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  533. set_target_properties(${CPPCMS_LIBS} PROPERTIES OUTPUT_NAME "cppcms${CPPCMS_SUFFIX}")
  534. if(WIN32)
  535. set_target_properties(${CPPCMS_LIBS} PROPERTIES VERSION 1 SOVERSION 1)
  536. else()
  537. set_target_properties(${CPPCMS_LIBS} PROPERTIES VERSION 1.0.0 SOVERSION 1)
  538. endif()
  539. set_target_properties(${CPPCMS_LIBS} PROPERTIES
  540. PUBLIC_HEADER "${CPPCMS_PUBLIC_HEADERS}")
  541. if(MSVC AND NOT DISABLE_STATIC)
  542. set_target_properties(cppcms-static PROPERTIES PREFIX "lib")
  543. endif(MSVC AND NOT DISABLE_STATIC)
  544. configure_file(config.cmake.h cppcms/config.h)
  545. install(TARGETS ${CPPCMS_LIBS} cppcms_config_find_param cppcms_scale
  546. RUNTIME DESTINATION bin
  547. LIBRARY DESTINATION lib
  548. ARCHIVE DESTINATION lib
  549. PUBLIC_HEADER DESTINATION include/cppcms)
  550. install(PROGRAMS cppcms_tmpl_cc cppcms_run
  551. DESTINATION bin)
  552. #############
  553. # TESTS
  554. #############
  555. set(CNF "${CMAKE_CURRENT_SOURCE_DIR}/tests")
  556. add_test(base64_test base64_test)
  557. add_test(encryptor_test encryptor_test)
  558. add_test(storage_test storage_test)
  559. add_test(json_test json_test)
  560. add_test(cache_backend_test cache_backend_test)
  561. add_test(form_test
  562. form_test "-c" "${CNF}/form_test.js"
  563. "--test-exec=${PYTHON} ${CNF}/form_test.py")
  564. add_test(forwarder_test
  565. forwarder_test "-c" "${CNF}/forwarder_test.js"
  566. "--test-exec=${PYTHON} ${CNF}/forwarder_test.py")
  567. add_test(jsonrpc_test
  568. jsonrpc_test "-c" "${CNF}/jsonrpc_test.js"
  569. "--test-exec=${PYTHON} ${CNF}/jsonrpc_test.py")
  570. foreach(TYPE async sync)
  571. add_test(proto_test_${TYPE}_http
  572. proto_test "-c" "${CNF}/proto_test.js"
  573. "--test-async=${TYPE}" "--service-api=http" "--service-port=8080" "--service-ip=127.0.0.1"
  574. "--test-exec=${PYTHON} ${CNF}/proto_test.py http")
  575. add_test(proto_test_${TYPE}_scgi
  576. proto_test "-c" "${CNF}/proto_test.js"
  577. "--test-async=${TYPE}" "--service-api=scgi" "--service-port=8080" "--service-ip=127.0.0.1"
  578. "--test-exec=${PYTHON} ${CNF}/proto_test.py scgi_tcp")
  579. if(NOT WIN32)
  580. add_test(proto_test_${TYPE}_scgi_unix
  581. proto_test "-c" "${CNF}/proto_test.js"
  582. "--test-async=${TYPE}" "--service-api=scgi" "--service-socket=/tmp/cppcms_test_socket"
  583. "--test-exec=${PYTHON} ${CNF}/proto_test.py scgi_unix")
  584. endif()
  585. endforeach()
  586. set_tests_properties(
  587. cache_backend_test
  588. forwarder_test
  589. jsonrpc_test
  590. proto_test_sync_http
  591. proto_test_async_http
  592. proto_test_sync_scgi
  593. proto_test_async_scgi
  594. PROPERTIES TIMEOUT 30)
  595. if(NOT WIN32)
  596. set_tests_properties(
  597. proto_test_sync_scgi_unix
  598. proto_test_async_scgi_unix
  599. PROPERTIES TIMEOUT 30)
  600. endif()