Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 30th, 2011  |  syntax: CMake  |  size: 12.61 KB  |  hits: 126  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
  2.  
  3. SET(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE true)
  4.  
  5. IF(COMMAND CMAKE_POLICY)
  6.   CMAKE_POLICY(SET CMP0002 OLD)
  7.   CMAKE_POLICY(SET CMP0003 OLD)
  8.   CMAKE_POLICY(SET CMP0005 OLD)
  9. ENDIF(COMMAND CMAKE_POLICY)
  10.  
  11. PROJECT(Proj)
  12. SET(CMAKE_MODULE_PATH ${WT_SOURCE_DIR} ${WT_SOURCE_DIR}/cmake)
  13.  
  14. SET(VERSION_SERIES 3)
  15. SET(VERSION_MAJOR 1)
  16. SET(VERSION_MINOR 11)
  17.  
  18. SET(WT_SOVERSION 30)
  19. SET(WTEXT_SOVERSION 30)
  20. SET(WTHTTP_SOVERSION 30)
  21. SET(WTFCGI_SOVERSION 30)
  22. SET(WTISAPI_SOVERSION 7)
  23. SET(WTDBO_SOVERSION 30)
  24. SET(WTDBOSQLITE3_SOVERSION 30)
  25. SET(WTDBOPOSTGRES_SOVERSION 30)
  26.  
  27. IF(NOT SHARED_LIBS)
  28.   IF(WIN32)
  29.     OPTION(SHARED_LIBS "Compile shared libraries" OFF)
  30.   ELSE(WIN32)
  31.     OPTION(SHARED_LIBS "Compile shared libraries" ON)
  32.   ENDIF(WIN32)
  33. ENDIF(NOT SHARED_LIBS)
  34.  
  35. #
  36. # Ubuntu patched this compiler to hell
  37. # gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
  38. #
  39. EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
  40.   ARGS --version
  41.   OUTPUT_VARIABLE GCC_COMPILER_VERSION
  42. )
  43.  
  44. IF(GCC_COMPILER_VERSION MATCHES ".*4\\.4\\.4\\-14ubuntu5.*")
  45.   MESSAGE(" ")
  46.   MESSAGE("    !!!!! WARNING Your compiler is BUGGY. !!!!! ")
  47.   MESSAGE(" ")
  48.   MESSAGE("    If possible, upgrade your compiler to e.g. g++ 4.5:")
  49.   MESSAGE(" ")
  50.   MESSAGE("       $ sudo apt-get install g++-4.5")
  51.   MESSAGE(" ")
  52.   MESSAGE("    And build using that compiler cmake -DCMAKE_CXX_COMPILER=g++-4.5")
  53.   MESSAGE(" ")
  54.   MESSAGE("    We will now disable all assertions as a work around, by")
  55.   MESSAGE("    building using -DNDEBUG. You will need to define this")
  56.   MESSAGE("    also for programs built using Wt")
  57.   MESSAGE(" ")
  58.   ADD_DEFINITIONS(-DNDEBUG)
  59. ENDIF(GCC_COMPILER_VERSION MATCHES ".*4\\.4\\.4\\-14ubuntu5.*")
  60.  
  61. IF(WIN32)
  62.   IF(SHARED_LIBS)
  63.     # See http://svn.boost.org/trac/boost/ticket/3465
  64.     SET(WT_NO_BOOST_INTRUSIVE true)
  65.   ENDIF(SHARED_LIBS)
  66. ENDIF(WIN32)
  67.  
  68. # Fixup Windows declspec stuff
  69. IF(NOT SHARED_LIBS)
  70.   SET(WT_STATIC true)
  71.   SET(WTHTTP_STATIC true)
  72.   SET(WT_EXT_STATIC true)
  73.   SET(WTDBO_STATIC true)
  74.   SET(WTDBOSQLITE3_STATIC true)
  75.   SET(WTDBOPOSTGRES_STATIC true)
  76. ENDIF(NOT SHARED_LIBS)
  77.  
  78. IF(NOT MULTI_THREADED)
  79.   OPTION(MULTI_THREADED "Build multi-threaded httpd deamon (if possible)" ON)
  80. ENDIF(NOT MULTI_THREADED)
  81.  
  82. SET(BUILD_SHARED_LIBS ${SHARED_LIBS})
  83.  
  84. # Default is to use cmake's boost discovery. The default will use wt's own
  85. # boost detection mechanism if one of the following is true:
  86. # - cmake version is too old (prior to 2.6 series)
  87. # - BOOST_COMPILER or BOOST_VERSION was defined (compatibility with existing
  88. #   build scripts)
  89. # - USE_BOOST_FRAMEWORK: we've adapted the vintage boost cmake find
  90. #   script to locate a boost.framework
  91. #
  92. IF(DEFINED BOOST_COMPILER OR DEFINED BOOST_VERSION OR USE_BOOST_FRAMEWORK)
  93.   SET(DEFAULT_WT_BOOST_DISCOVERY TRUE)
  94. ELSE(DEFINED BOOST_COMPILER OR DEFINED BOOST_VERSION OR USE_BOOST_FRAMEWORK)
  95.   SET(DEFAULT_WT_BOOST_DISCOVERY FALSE)
  96. ENDIF(DEFINED BOOST_COMPILER OR DEFINED BOOST_VERSION OR USE_BOOST_FRAMEWORK)
  97.  
  98. # There's no decent boost discovery prior to cmake 2.6
  99. IF(CMAKE_MAJOR_VERSION LESS 2)
  100.   SET(DEFAULT_WT_BOOST_DISCOVERY TRUE)
  101. ELSEIF(CMAKE_MAJOR_VERSION EQUAL 2)
  102.     IF(CMAKE_MINOR_VERSION LESS 6)
  103.       SET(DEFAULT_WT_BOOST_DISCOVERY TRUE)
  104.     ELSEIF(CMAKE_MINOR_VERSION EQUAL 6)
  105.       IF(CMAKE_TINY_VERSION LESS 2)
  106.         # Pau says: 2.6.0 and 2.6.1 are not very good
  107.         SET(DEFAULT_WT_BOOST_DISCOVERY TRUE)
  108.       ENDIF(CMAKE_TINY_VERSION LESS 2)
  109.     ENDIF(CMAKE_MINOR_VERSION LESS 6)
  110. ENDIF(CMAKE_MAJOR_VERSION LESS 2)
  111.  
  112. SET(WT_BOOST_DISCOVERY ${DEFAULT_WT_BOOST_DISCOVERY} CACHE BOOL "Use Wt's boost discovery method rather than the cmake 2.6+ method")
  113.  
  114. SET(DEBUG_LIB_POSTFIX "d" CACHE STRING "String appended to debug libraries")
  115.  
  116. SET(LIB_INSTALL_DIR "lib" CACHE STRING
  117.   "Name for library directory within ${CMAKE_INSTALL_PREFIX}")
  118.  
  119. IF(WIN32)
  120.  
  121.   SET(RUNDIR "c:/witty") # Does not apply to win32
  122.  
  123.   IF(NOT DEFINED CONFIGDIR)
  124.     SET(CONFIGDIR ${RUNDIR} CACHE STRING "Path for the configuration files")
  125.   ENDIF(NOT DEFINED CONFIGDIR)
  126.  
  127.   SET(USERLIB_PREFIX_DEFAULT "c:/libraries")
  128.   IF(MSVC)
  129.     SET(BUILD_PARALLEL "/MP" CACHE STRING "MSVC option for parallel builds (/MP or /MPx)")
  130.   ENDIF(MSVC)
  131.  
  132. ELSE(WIN32)
  133.  
  134.   SET(RUNDIR "/var/run/wt" CACHE PATH
  135.     "Default path for wt session management (only used by FCGI connector; not relative to CMAKE_INSTALL_PREFIX)")
  136.  
  137.   IF( NOT DEFINED CONFIGDIR )
  138.     SET(CONFIGDIR "/etc/wt" CACHE STRING "Path for the configuration files")
  139.   ENDIF( NOT DEFINED CONFIGDIR )
  140.  
  141.   SET(USERLIB_PREFIX_DEFAULT "/usr")
  142.  
  143. ENDIF(WIN32)
  144.  
  145. IF(DEFINED USERLIB_ROOT) # Deprecated <= 3.1.3
  146.   SET(USERLIB_PREFIX ${USERLIB_ROOT} CACHE PATH
  147.     "Installation prefix of dependency libraries (by USERLIB_ROOT)")
  148. ELSE(DEFINED USERLIB_ROOT)
  149.   SET(USERLIB_PREFIX ${USERLIB_PREFIX_DEFAULT} CACHE PATH
  150.     "Installation prefix of dependency libraries")
  151. ENDIF(DEFINED USERLIB_ROOT)
  152.  
  153. IF(WIN32)
  154.   SET(BOOST_PREFIX_DEFAULT "c:/Program Files/Boost")
  155.   OPTION(BOOST_DYNAMIC "Link to boost DLLs (OFF means static link)" OFF)
  156. ELSE(WIN32)
  157.   SET(BOOST_PREFIX_DEFAULT ${USERLIB_PREFIX})
  158. ENDIF(WIN32)
  159.  
  160. IF(DEFINED BOOST_DIR) # Deprecated <= 3.1.3
  161.   SET(BOOST_PREFIX ${BOOST_DIR} CACHE PATH
  162.     "Installation prefix of boost libraries (by BOOST_DIR)")
  163. ELSE(DEFINED BOOST_DIR)
  164.   SET(BOOST_PREFIX ${BOOST_PREFIX_DEFAULT} CACHE PATH
  165.     "Installation prefix of boost libraries")
  166. ENDIF(DEFINED BOOST_DIR)
  167.  
  168. SET(FCGI_PREFIX ${USERLIB_PREFIX} CACHE PATH
  169.   "Installation prefix of fcgi library (overrides USERLIB_PREFIX)")
  170. SET(POSTGRES_PREFIX ${USERLIB_PREFIX} CACHE PATH
  171.   "Installation prefix of postgresql library (overrides USERLIB_PREFIX)")
  172. SET(MYSQL_PREFIX ${USERLIB_PREFIX} CACHE PATH
  173.   "Installation prefix of mysql and mysql++ libraries "
  174.   "(overrides USERLIB_PREFIX)")
  175. SET(SQLITE3_PREFIX ${USERLIB_PREFIX} CACHE PATH
  176.   "Installation prefix of sqlite3 library (overrides USERLIB_PREFIX)")
  177. SET(HARU_PREFIX ${USERLIB_PREFIX} CACHE PATH
  178.   "Installation prefix of libharu library (overrides USERLIB_PREFIX)")
  179. SET(SSL_PREFIX ${USERLIB_PREFIX} CACHE PATH
  180.   "Installation prefix of SSL library (overrides USERLIB_PREFIX)")
  181. SET(ZLIB_PREFIX ${USERLIB_PREFIX} CACHE PATH
  182.   "Installation prefix of zlib library (overrides USERLIB_PREFIX)")
  183. SET(GM_PREFIX ${USERLIB_PREFIX} CACHE PATH
  184.   "Installation prefix of GraphicsMgick library (overrides GM_PREFIX)")
  185.  
  186. OPTION(DEBUG "Support for debugging, must be enabled also in wt_config.xml" OFF)
  187. IF(CYGWIN)
  188.   OPTION(BUILD_TESTS "Build Wt tests" OFF)
  189. ELSE(CYGWIN)
  190.   OPTION(BUILD_TESTS "Build Wt tests" ON)
  191. ENDIF(CYGWIN)
  192.  
  193. ADD_DEFINITIONS(-DWT_WITH_OLD_INTERNALPATH_API)
  194. IF(CYGWIN)
  195.   ADD_DEFINITIONS(-D__USE_W32_SOCKETS)
  196. ENDIF(CYGWIN)
  197.  
  198. MARK_AS_ADVANCED( CONFIGDIR )
  199.  
  200. SET(CONFIGURATION "${CONFIGDIR}/wt_config.xml" CACHE PATH "Path to the wt configuration file")
  201. SET(WTHTTP_CONFIGURATION ${CONFIGDIR}/wthttpd CACHE PATH "Path for the wthttpd configuration file")
  202.  
  203. SET(WEBUSER apache CACHE STRING "Webserver username (e.g. apache or www)")
  204. SET(WEBGROUP apache CACHE STRING "Webserver groupname (e.g. apache or www or users)")
  205. IF(WIN32)
  206.   SET(CONNECTOR_FCGI FALSE)
  207.   IF(NOT MINGW)
  208.     OPTION(CONNECTOR_ISAPI "Compile in ISAPI connector (libwtisapi) ?" ON)
  209.   ENDIF(NOT MINGW)
  210. ELSE(WIN32)
  211.   OPTION(CONNECTOR_FCGI "Compile in FCGI connector (libwtfcgi) ?" ON)
  212.   SET(CONNECTOR_ISAPI OFF)
  213. ENDIF(WIN32)
  214. OPTION(CONNECTOR_HTTP "Compile in stand-alone httpd connector (libwthttp) ?" ON)
  215. SET(EXAMPLES_CONNECTOR wthttp CACHE STRING "Connector used for examples")
  216.  
  217. include (CheckSymbolExists)
  218.  
  219. INCLUDE(FindWt.txt)
  220.  
  221. INCLUDE(FindThreads)
  222.  
  223. IF(NOT BOOST_WT_FOUND)
  224.   SET(ERR
  225.      "Could not find a boost installation in " ${BOOST_PREFIX} ".\n\n"
  226.       "There are two methods in Wt to find boost:\n\n"
  227.       "1. Find boost through cmake (recommended)\n"
  228.       "This requires cmake 2.6, and is in "
  229.       "that case the default (unless BOOST_COMPILER or BOOST_VERSION is "
  230.       "defined). This method requires a multi-threaded boost installation.\n"
  231.       "You may need to add your boost version number to "
  232.       "Boost_ADDITIONAL_VERSIONS, and/or set BOOST_PREFIX to the location "
  233.       "where boost is installed.\n\n"
  234.       "2. Use the Wt-proprietary method to find boost.\n"
  235.       "This requires you to define three variables:\n"
  236.       "BOOST_PREFIX: set to the directory where you installed boost\n"
  237.       "BOOST_COMPILER: set to the compiler signature as you find them in "
  238.       "library names (e.g.: gcc42)\n"
  239.       "BOOST_VERSION: set to the boost version, again as you find them in "
  240.       "the library names (e.g.: 1_38)\n\n"
  241.       "Note 1: WT_BOOST_DISCOVERY is the variable that selects the boost "
  242.       "discovery method. When set to false, method 1 is used (default if "
  243.       "cmake version is recent enough and BOOST_COMPILER and BOOST_VERSION "
  244.       "are not defined). When set to true, method 2 is used.\n"
  245.       "Note 2: the code to discover boost is located in cmake/WtFindBoost.txt\n"
  246.       "Note 3: on windows, set BOOST_PREFIX to the full path, eg "
  247.       "c:/Program Files/boost/boost_1_38\n\n"
  248.       "Note 4: if you do not have boost.random, set WT_NO_BOOST_RANDOM to ON"
  249.       "Wt requires the following C++ boost libraries: date_time, regex, program_options, signals, random, and optionally thread")
  250.   MESSAGE(FATAL_ERROR ${ERR})
  251. ENDIF(NOT BOOST_WT_FOUND)
  252.  
  253. IF(BOOST_WT_MT_FOUND)
  254.   IF(MULTI_THREADED)
  255.     MESSAGE("** Enabling multi threading.")
  256.     SET(MULTI_THREADED_BUILD true)
  257.  
  258.     ADD_DEFINITIONS(-DWT_THREADED -D_REENTRANT -DBOOST_SPIRIT_THREADSAFE)
  259.   ELSE(MULTI_THREADED)
  260.     MESSAGE("** Disabling multi threading.")
  261.     SET(MULTI_THREADED_BUILD false)
  262.  
  263.     ADD_DEFINITIONS(-DBOOST_DISABLE_THREADS -DSQLITE_THREADSAFE=0)
  264.   ENDIF(MULTI_THREADED)
  265. ELSE(BOOST_WT_MT_FOUND)
  266.   SET(MULTI_THREADED_BUILD false)
  267.   MESSAGE("** Disabling multi threading: could not find multi-threaded boost libraries")
  268.   ADD_DEFINITIONS(-DBOOST_DISABLE_THREADS -DSQLITE_THREADSAFE=0)
  269. ENDIF(BOOST_WT_MT_FOUND)
  270.  
  271. FIND_PACKAGE(Doxygen)
  272.  
  273. # Boost is used nearly everywhere, so we can put these here
  274. INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIRS})
  275. LINK_DIRECTORIES(${BOOST_LIB_DIRS})
  276. IF(WIN32)
  277.   IF(BOOST_DYNAMIC)
  278.     ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK)
  279.   ELSE(BOOST_DYNAMIC)
  280.     # You could expect that this is the default when BOOST_ALL_DYN_LINK
  281.     # is not set, but this is problematic for cygwin
  282.     ADD_DEFINITIONS(-DBOOST_THREAD_USE_LIB)
  283.   ENDIF(BOOST_DYNAMIC)
  284.   ADD_DEFINITIONS(
  285.       -D_CRT_SECURE_NO_WARNINGS
  286.       -Dinline=__inline
  287.       -D_SCL_SECURE_NO_WARNINGS
  288.       )
  289. ENDIF(WIN32)
  290.  
  291. IF(NOT CMAKE_BUILD_TYPE)
  292.   SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
  293.       "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
  294.       FORCE)
  295. ENDIF(NOT CMAKE_BUILD_TYPE)
  296.  
  297. IF(DEBUG)
  298.   SET(WT_DEBUG_ENABLED 1)
  299. ELSE(DEBUG)
  300.   SET(WT_DEBUG_ENABLED 0)
  301. ENDIF(DEBUG)
  302.  
  303. ADD_CUSTOM_TARGET(doc)
  304.  
  305. IF (ASCIIDOC_FOUND)
  306.   MACRO (ASCIIDOC_FILE target infile outfile)
  307.     ADD_CUSTOM_TARGET(${target}
  308.        ${ASCIIDOC_EXECUTABLE} -a toc -a numbered -o ${outfile} ${infile}
  309.        COMMENT "Asciidoc ${infile}")
  310.     ADD_DEPENDENCIES(doc ${target})
  311.   ENDMACRO (ASCIIDOC_FILE)
  312. ENDIF (ASCIIDOC_FOUND)
  313.  
  314. IF (DOXYGEN_FOUND)
  315.   ADD_CUSTOM_TARGET(doxygen
  316.     ${DOXYGEN_EXECUTABLE}
  317.     WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  318.     COMMENT "Doxygen ...")
  319.   ADD_DEPENDENCIES(doc doxygen)
  320.   ADD_CUSTOM_TARGET(doxygen-examples
  321.     ${DOXYGEN_EXECUTABLE}
  322.     WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/examples
  323.     COMMENT "Doxygen for examples ...")
  324.   ADD_DEPENDENCIES(doc doxygen-examples)
  325.  ENDIF (DOXYGEN_FOUND)
  326.  
  327. SUBDIRS(src)
  328.  
  329. IF( NOT DEFINED WT_CMAKE_FINDER_INSTALL_DIR )
  330.   SET( WT_CMAKE_FINDER_INSTALL_DIR "share/cmake-2.4/Modules" )
  331. ENDIF( NOT DEFINED WT_CMAKE_FINDER_INSTALL_DIR)
  332.  
  333. INSTALL(FILES ${PROJECT_SOURCE_DIR}/cmake/FindWt.cmake DESTINATION
  334.     ${CMAKE_INSTALL_PREFIX}/${WT_CMAKE_FINDER_INSTALL_DIR} )
  335.  
  336. IF(INSTALL_RESOURCES)
  337. INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/resources DESTINATION
  338.     ${CMAKE_INSTALL_PREFIX}/share/Wt/)
  339. ENDIF(INSTALL_RESOURCES)
  340.  
  341. IF(NOT EXISTS ${DESTDIR}${CONFIGDIR}/wt_config.xml)
  342.   INSTALL(FILES ${WT_BINARY_DIR}/wt_config.xml DESTINATION ${CONFIGDIR})
  343. ENDIF (NOT EXISTS ${DESTDIR}${CONFIGDIR}/wt_config.xml)
  344.  
  345. # Compile time constants & make sure our build finds it
  346. FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Wt)
  347. SET(WCONFIG_H_PATH ${CMAKE_CURRENT_BINARY_DIR}/Wt/WConfig.h)
  348. CONFIGURE_FILE(
  349.   ${WT_SOURCE_DIR}/WConfig.h.in
  350.   ${WCONFIG_H_PATH}
  351. )
  352. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
  353. INSTALL_FILES(/include/Wt FILES ${WCONFIG_H_PATH})
  354.  
  355. # Generate wt_config.xml from wt_config.xml.in
  356. CONFIGURE_FILE(
  357.   ${WT_SOURCE_DIR}/wt_config.xml.in
  358.   ${WT_BINARY_DIR}/wt_config.xml
  359. )
  360.  
  361.  
  362.