2010-05-18 00:17:14 +02:00
project ( Trinity )
2009-01-18 11:07:43 +01:00
cmake_minimum_required ( VERSION 2.6 )
2009-01-17 09:23:33 -05:00
cmake_policy ( SET CMP0005 OLD )
2009-06-29 00:47:19 +02:00
include ( CheckIncludeFiles )
2009-01-17 09:23:33 -05:00
include ( cmake/FindAce.cmake )
include ( cmake/FindMySql.cmake )
2009-07-24 23:15:43 +02:00
include ( cmake/FindReadline.cmake )
2009-09-06 00:39:13 +02:00
include ( cmake/FindTermcap.cmake )
2010-05-18 00:17:14 +02:00
include ( cmake/PCH.cmake )
# Force out-of-source build
string ( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" BUILDING_IN_SOURCE )
if ( BUILDING_IN_SOURCE )
2010-05-18 04:28:13 +02:00
message ( FATAL_ERROR "This project requires an out of source build. Remove the file 'CMakeCache.txt' found in this directory before continuing, and create a separate build directory and run 'cmake path_to_project [options]' from there." )
2010-05-18 00:17:14 +02:00
endif ( BUILDING_IN_SOURCE )
# Select the Release build configuration by default.
if ( NOT CMAKE_BUILD_TYPE )
set ( CMAKE_BUILD_TYPE "Release" )
endif ( NOT CMAKE_BUILD_TYPE )
2009-01-17 09:23:33 -05:00
CONFIGURE_FILE (
2010-05-18 00:17:14 +02:00
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY )
add_custom_target ( uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
2010-06-07 21:58:26 +02:00
option ( CENTOS "CENTOS" 0 )
2010-05-18 00:17:14 +02:00
option ( DO_CLI "With CLI" 1 )
option ( DO_DEBUG "Debug mode" 0 )
2010-06-07 21:58:26 +02:00
option ( DO_MYSQL "With MySQL support" 1 )
2010-05-18 00:17:14 +02:00
option ( DO_PCH "Use precompiled headers" 1 )
2010-06-07 21:58:26 +02:00
option ( DO_RA "With RA" 0 )
option ( DO_SCRIPTS "With trinityscripts" 1 )
option ( DO_SQL "Copy SQL files" 0 )
2010-06-06 23:53:50 +02:00
option ( DO_TOOLS "Compile tools" 0 )
2010-06-07 21:58:26 +02:00
option ( DO_WARN "Enable all compile warnings" 0 )
2010-05-18 00:17:14 +02:00
set ( GENREV_SRC
2010-06-06 12:51:59 +02:00
src/genrevision/genrevision.cpp
2009-01-17 09:23:33 -05:00
)
2010-05-18 00:17:14 +02:00
if ( DO_DEBUG )
add_executable ( genrev
2009-12-14 14:50:46 -05:00
${ GENREV_SRC }
)
2010-05-18 00:17:14 +02:00
add_custom_target ( "revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/genrev"
${ CMAKE_SOURCE_DIR }
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/src/shared"
2009-12-14 14:50:46 -05:00
DEPENDS genrev
)
else ( DO_DEBUG )
2010-05-18 00:17:14 +02:00
add_executable ( genrev
2009-12-14 14:50:46 -05:00
${ GENREV_SRC }
)
2010-05-18 00:17:14 +02:00
add_custom_target ( "revision.h" ALL
COMMAND "${CMAKE_BINARY_DIR}/genrev"
${ CMAKE_SOURCE_DIR }
2010-06-06 14:08:07 +02:00
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/src/server/shared"
2009-12-14 14:50:46 -05:00
DEPENDS genrev
)
2010-05-18 00:17:14 +02:00
endif ( DO_DEBUG )
2009-01-17 09:23:33 -05:00
2010-05-18 00:17:14 +02:00
execute_process (
2009-01-17 09:23:33 -05:00
COMMAND hg tip --template {rev}
2010-05-18 00:17:14 +02:00
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
2009-01-17 09:23:33 -05:00
OUTPUT_VARIABLE HG_REVISION
)
2010-02-15 08:05:02 -07:00
message ( "* TrinityCore revision: ${HG_REVISION}" )
2009-01-17 09:23:33 -05:00
2010-05-18 00:17:14 +02:00
if ( PREFIX )
set ( CMAKE_INSTALL_PREFIX ${ PREFIX } )
endif ( PREFIX )
2009-01-17 09:23:33 -05:00
if ( CONF_DIR )
else ( CONF_DIR )
2010-05-18 00:17:14 +02:00
set ( CONF_DIR ${ PREFIX } /etc )
2009-01-17 09:23:33 -05:00
endif ( CONF_DIR )
2010-05-18 00:17:14 +02:00
set ( LIBSDIR ${ CMAKE_INSTALL_PREFIX } /lib )
2009-01-17 09:23:33 -05:00
message ( "* Will install to: ${CMAKE_INSTALL_PREFIX}" )
message ( "* With config dir at: ${CONF_DIR}" )
2009-01-28 00:57:25 +01:00
message ( "* Libs install dir at: ${LIBSDIR}" )
2009-01-17 09:23:33 -05:00
2010-05-18 00:17:14 +02:00
find_library ( SSLLIB NAMES ssl DOC "SSL library" )
find_library ( ZLIB z "Zlib library" )
2009-01-17 09:23:33 -05:00
2010-05-18 00:17:14 +02:00
if ( DO_MYSQL )
message ( "* With MySQL" )
2009-01-17 09:23:33 -05:00
FIND_MYSQL ()
ADD_DEFINITIONS ( -DDO_MYSQL )
2010-05-18 00:17:14 +02:00
endif ( DO_MYSQL )
2009-01-17 09:23:33 -05:00
2010-01-21 08:23:30 +02:00
if ( DO_SCRIPTS )
2010-01-24 20:02:05 +01:00
message ( "* With Trinity Scripts" )
ADD_DEFINITIONS ( -DDO_SCRIPTS )
add_definitions ( -D_TRINITY_SCRIPT_CONFIG=' "${CONF_DIR}/trinitycore.conf" ' )
2010-01-21 08:23:30 +02:00
else ( DO_SCRIPTS )
2010-01-24 20:02:05 +01:00
message ( "* Without Trinity Scripts" )
2010-01-21 08:23:30 +02:00
endif ( DO_SCRIPTS )
2009-01-17 09:23:33 -05:00
message ( "-- Miscellaneus options:" )
if ( DO_CLI )
2010-05-18 00:17:14 +02:00
message ( "* With CLI" )
add_definitions ( -DENABLE_CLI )
2009-01-17 09:23:33 -05:00
else ( DO_CLI )
2010-05-18 00:17:14 +02:00
message ( * Without CLI )
2009-01-17 09:23:33 -05:00
endif ( DO_CLI )
if ( DO_RA )
2010-05-18 00:17:14 +02:00
message ( "* With RA" )
add_definitions ( -DENABLE_RA )
2009-01-17 09:23:33 -05:00
else ( DO_RA )
2010-05-18 00:17:14 +02:00
message ( "* Without RA" )
2009-01-17 09:23:33 -05:00
endif ( DO_RA )
if ( DO_DEBUG )
2010-05-18 00:17:14 +02:00
message ( "* Debug mode ON" )
add_definitions ( -g -DTRINITY_DEBUG )
2009-01-17 09:23:33 -05:00
endif ( DO_DEBUG )
2009-03-18 20:51:13 +01:00
if ( DO_WARN )
message ( "* All warnings mode" )
add_definitions ( -Wall -Wfatal-errors -Wextra )
endif ( DO_WARN )
2010-06-07 21:58:26 +02:00
if ( DO_SQL )
message ( "* Installing SQL files" )
else ( DO_SQL )
message ( "* NOT installing SQL files" )
endif ( DO_SQL )
if ( DO_PCH )
message ( "* Using precompiled headers" )
else ( DO_PCH )
message ( "* NOT using precompiled headers" )
endif ( DO_PCH )
if ( DO_TOOLS )
message ( "* With Tools" )
else ( DO_TOOLS )
message ( "* Without Tools" )
endif ( DO_TOOLS )
2010-05-18 00:17:14 +02:00
if ( UNIX )
if ( CENTOS )
2009-09-06 05:23:33 +02:00
add_definitions ( -DCENTOS )
2010-05-18 00:17:14 +02:00
message ( "* Building with termcap" )
2009-09-06 05:23:33 +02:00
FIND_TERMCAP ()
2010-05-18 00:17:14 +02:00
else ( CENTOS )
message ( "* Building with readline" )
2009-09-06 05:23:33 +02:00
FIND_READLINE ()
2010-05-18 00:17:14 +02:00
endif ( CENTOS )
endif ( UNIX )
2009-06-19 22:46:11 +02:00
2009-01-17 09:23:33 -05:00
FIND_ACE ( ACE )
if ( ACE_FOUND )
2010-05-18 00:17:14 +02:00
message ( STATUS "Found ACE library: ${ACE_LIBRARY}" )
message ( STATUS "Include dir is: ${ACE_INCLUDE_DIR}" )
2009-01-18 11:07:43 +01:00
else ( ACE_FOUND )
2010-05-18 00:17:14 +02:00
message ( SEND_ERROR "** ACE library not found! Trinity Core cannot be compiled!" )
message ( SEND_ERROR "** Please build ACE from http://www.cs.wustl.edu/~schmidt/ACE.html" )
#For now remove msg about install from repo, as ubuntu/debian don't have needed ver in repos.
#message(SEND_ERROR "** your distro may provide a binary for ACE e.g. for ubuntu try apt-get install libace-dev")
return ()
#set(BUILD_ACE 1)
#set(ACE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/dep/ACE_wrappers ${CMAKE_BINARY_DIR}/dep/ACE_wrappers")
#set(ACE_LIBRARY ACE)
#message(STATUS "I will try to build ACE from: ${ACE_INCLUDE_DIR}")
#message(STATUS "And link using: ${ACE_LIBRARY}")
2009-01-17 09:23:33 -05:00
endif ( ACE_FOUND )
2009-07-25 16:34:22 +02:00
#somehow line below don't work. so for now change it to if exist
#check_include_files(${ACE_INCLUDE_DIR}/ace/Stack_Trace.h HAVE_ACE_STACK_TRACE_H)
2010-05-18 00:17:14 +02:00
if ( EXISTS ${ ACE_INCLUDE_DIR } /ace/Stack_Trace.h )
set ( HAVE_ACE_STACK_TRACE_H 1 )
else ( EXISTS ${ ACE_INCLUDE_DIR } /ace/Stack_Trace.h )
2009-07-25 16:34:22 +02:00
message ( STATUS "** Your libace is out of date. Please update your libace!" )
2010-05-18 00:17:14 +02:00
endif ( EXISTS ${ ACE_INCLUDE_DIR } /ace/Stack_Trace.h )
2009-07-25 16:34:22 +02:00
2009-01-17 09:23:33 -05:00
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /config.h.cmake ${ CMAKE_CURRENT_BINARY_DIR } /config.h )
2010-05-18 00:17:14 +02:00
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set ( MACOSX 1 )
set ( OSX_LIBS /opt/local/lib/libcrypto.dylib )
2009-02-20 18:22:39 -06:00
add_definitions ( -D__ASSERTMACROS__ )
2010-05-18 00:17:14 +02:00
endif ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
2009-02-20 18:22:39 -06:00
2009-01-17 09:23:33 -05:00
add_definitions ( --no-warnings ) #to make build look nice, no gcc nazi warnings.
2010-05-18 00:17:14 +02:00
set ( CMAKE_SKIP_BUILD_RPATH FALSE )
set ( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE )
set ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" )
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
2009-01-18 09:46:15 -05:00
2009-01-17 09:23:33 -05:00
add_subdirectory ( src )
2010-04-13 16:11:04 +02:00
if ( DO_SQL )
2010-05-18 00:17:14 +02:00
message ( "* Copy SQL files ON" )
add_subdirectory ( sql )
2010-04-13 16:11:04 +02:00
endif ( DO_SQL )