|
| 1 | +# |
| 2 | +# Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/> |
| 3 | +# |
| 4 | +# This program is free software; you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation; either version 2 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program; if not, write to the Free Software |
| 16 | +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | +# |
| 18 | + |
| 19 | +## magic to include revision data in SD2 version string |
| 20 | +# revision.h: FORCE |
| 21 | +# $(top_builddir)/src/tools/genrevision/genrevision $(srcdir) |
| 22 | + |
| 23 | +file(GLOB_RECURSE mangosscript_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h) |
| 24 | + |
| 25 | +source_group("Other" |
| 26 | + REGULAR_EXPRESSION .* |
| 27 | +) |
| 28 | + |
| 29 | +foreach(SRC ${mangosscript_SRCS}) |
| 30 | + get_filename_component(PTH ${SRC} PATH) |
| 31 | + if(PTH) |
| 32 | + if(NOT XCODE) # FIXME: Xcode Generator has bug with nested dirs |
| 33 | + string(REPLACE "/" "\\\\" PTH ${PTH}) |
| 34 | + endif() |
| 35 | + source_group(${PTH} FILES ${SRC}) |
| 36 | + endif() |
| 37 | +endforeach(SRC) |
| 38 | + |
| 39 | +include_directories( |
| 40 | + ${CMAKE_CURRENT_SOURCE_DIR}/base |
| 41 | + ${CMAKE_CURRENT_SOURCE_DIR}/include |
| 42 | + ${CMAKE_SOURCE_DIR}/src/shared |
| 43 | + ${CMAKE_SOURCE_DIR}/src/framework |
| 44 | + ${CMAKE_SOURCE_DIR}/src/game |
| 45 | + ${CMAKE_SOURCE_DIR}/dep/include |
| 46 | + ${CMAKE_BINARY_DIR} |
| 47 | + ${ACE_INCLUDE_DIR} |
| 48 | + ${MYSQL_INCLUDE_DIR} |
| 49 | +) |
| 50 | + |
| 51 | +if(PCH) |
| 52 | + include_directories( |
| 53 | + ${CMAKE_CURRENT_BINARY_DIR} |
| 54 | + ) |
| 55 | +endif() |
| 56 | + |
| 57 | +add_library(mangosscript SHARED |
| 58 | + ${mangosscript_SRCS} |
| 59 | +) |
| 60 | + |
| 61 | +if(WIN32) |
| 62 | + target_link_libraries(mangosscript |
| 63 | + mangosd # FIXME: could this be done for unix? because unix won't generate exe.libs |
| 64 | + ${ACE_LIBRARIES} |
| 65 | + debug ${WIN_DEBUGLIBS} |
| 66 | + ) |
| 67 | +endif() |
| 68 | + |
| 69 | +add_dependencies(mangosscript revision.h) |
| 70 | +if(NOT ACE_USE_EXTERNAL) |
| 71 | + add_dependencies(mangosscript ACE_Project) |
| 72 | +# add_dependencies(mangosscript ace) |
| 73 | +endif() |
| 74 | + |
| 75 | +if(UNIX) |
| 76 | + set(mangosscript_LINK_FLAGS "-pthread") |
| 77 | + if(APPLE) |
| 78 | + set(mangosscript_LINK_FLAGS "-framework Carbon ${mangosscript_LINK_FLAGS}") |
| 79 | + # Needed for the linking because of the missing symbols |
| 80 | + set(mangosscript_LINK_FLAGS "-Wl,-undefined -Wl,dynamic_lookup ${mangosscript_LINK_FLAGS}") |
| 81 | + endif() |
| 82 | + |
| 83 | + if(APPLE) |
| 84 | + set(mangosscript_PROPERTIES INSTALL_NAME_DIR "${LIBS_DIR}") |
| 85 | + else() |
| 86 | + set(mangosscript_PROPERTIES INSTALL_RPATH ${LIBS_DIR}) |
| 87 | + endif() |
| 88 | + |
| 89 | + # Run out of build tree |
| 90 | + set(mangosscript_PROPERTIES |
| 91 | + ${mangosscript_PROPERTIES} |
| 92 | + BUILD_WITH_INSTALL_RPATH OFF |
| 93 | + ) |
| 94 | + |
| 95 | + set_target_properties(mangosscript PROPERTIES |
| 96 | + LINK_FLAGS ${mangosscript_LINK_FLAGS} |
| 97 | + ${mangosscript_PROPERTIES} |
| 98 | + ) |
| 99 | +endif() |
| 100 | + |
| 101 | +# Because size for linker is to big - seriously ?! |
| 102 | +if(WIN32) |
| 103 | + set_target_properties(mangosscript PROPERTIES |
| 104 | + LINK_FLAGS_DEBUG "/DEBUG /INCREMENTAL:NO" |
| 105 | + ) |
| 106 | +endif() |
| 107 | + |
| 108 | +## libtool settings |
| 109 | +# API versioning |
| 110 | +# Link against dependencies |
| 111 | +# How to increase version info: |
| 112 | +# - only bug fixes implemented: |
| 113 | +# bump the version to LTMANGOS_CURRENT:LTMANGOS_REVISION+1:LTMANGOS_AGE |
| 114 | +# - augmented the interface: |
| 115 | +# bump the version to LTMANGOS_CURRENT+1:0:LTMANGOS_AGE+1 |
| 116 | +# - broken old interface: |
| 117 | +# bump the version to LTMANGOS_CURRENT+1:0:0 |
| 118 | +# set(LTMANGOS_CURRENT 0) |
| 119 | +# set(LTMANGOS_REVISION 0) |
| 120 | +# set(LTMANGOS_AGE 0) |
| 121 | +# set_target_properties(script PROPERTIES LINK_FLAGS |
| 122 | +# "-version-info ${LTMANGOS_CURRENT}:${LTMANGOS_REVISION}:${LTMANGOS_AGE}" |
| 123 | +# ) |
| 124 | + |
| 125 | +# Generate precompiled header |
| 126 | +if(PCH) |
| 127 | + if(MSVC OR XCODE) |
| 128 | + if(MSVC) |
| 129 | + set(mangosscript_pch "${CMAKE_CURRENT_SOURCE_DIR}/include/precompiled.cpp") |
| 130 | + endif() |
| 131 | + add_native_precompiled_header(mangosscript ${CMAKE_CURRENT_SOURCE_DIR}/include/precompiled.h) |
| 132 | + elseif(CMAKE_COMPILER_IS_GNUCXX) |
| 133 | + add_precompiled_header(mangosscript ${CMAKE_CURRENT_SOURCE_DIR}/include/precompiled.h) |
| 134 | + endif() |
| 135 | +endif() |
| 136 | + |
| 137 | +# LIBRARY = dyld / so, RUNTIME = dll |
| 138 | +install(TARGETS mangosscript |
| 139 | + LIBRARY DESTINATION ${LIBS_DIR} |
| 140 | + RUNTIME DESTINATION ${LIBS_DIR} |
| 141 | +) |
| 142 | + |
| 143 | +install(FILES scriptdev2.conf.dist.in DESTINATION ${CONF_DIR} RENAME scriptdev2.conf.dist) |
0 commit comments