From f817e3714747b39a364e99c536e0b802b24fd2c3 Mon Sep 17 00:00:00 2001 From: flaviojs Date: Sun, 10 Jul 2011 15:29:57 +0000 Subject: * CMake: lowered required version to 2.8.3 and moved custom cmake modules to 3rdparty/cmake. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14897 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/CMakeLists.txt | 1 + 3rdparty/cmake/FindMYSQL.cmake | 35 +++++++++++++++++++++++++++++++++++ 3rdparty/cmake/FindPCRE.cmake | 35 +++++++++++++++++++++++++++++++++++ 3rdparty/mysql/CMakeLists.txt | 1 - 3rdparty/mysql/FindMYSQL.cmake | 35 ----------------------------------- 3rdparty/pcre/CMakeLists.txt | 1 - 3rdparty/pcre/FindPCRE.cmake | 35 ----------------------------------- CMakeLists.txt | 27 +++++++++++++++++++++++++-- Changelog-Trunk.txt | 1 + 9 files changed, 97 insertions(+), 74 deletions(-) create mode 100644 3rdparty/cmake/FindMYSQL.cmake create mode 100644 3rdparty/cmake/FindPCRE.cmake delete mode 100644 3rdparty/mysql/FindMYSQL.cmake delete mode 100644 3rdparty/pcre/FindPCRE.cmake diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 3e7cb4cc4..a63321033 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -47,6 +47,7 @@ macro( CONFIGURE_WITH_LOCAL_OR_SYSTEM name ) endmacro( CONFIGURE_WITH_LOCAL_OR_SYSTEM ) +set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH} ) add_subdirectory( msinttypes ) add_subdirectory( mt19937ar ) add_subdirectory( mysql ) diff --git a/3rdparty/cmake/FindMYSQL.cmake b/3rdparty/cmake/FindMYSQL.cmake new file mode 100644 index 000000000..0a07f3612 --- /dev/null +++ b/3rdparty/cmake/FindMYSQL.cmake @@ -0,0 +1,35 @@ +# - Find mysqlclient +# Find the native MySQL includes and library +# +# MYSQL_INCLUDE_DIRS - where to find mysql.h, etc. +# MYSQL_LIBRARIES - mysqlclient library. +# MYSQL_FOUND - True if mysqlclient is found. +# + +find_path( MYSQL_INCLUDE_DIRS "mysql.h" + PATHS + "/usr/include/mysql" + "/usr/local/include/mysql" + "$ENV{PROGRAMFILES}/MySQL/*/include" + "$ENV{SYSTEMDRIVE}/MySQL/*/include" ) + +find_library( MYSQL_LIBRARIES + NAMES "mysqlclient" "mysqlclient_r" + PATHS + "/usr/lib/mysql" + "/usr/local/lib/mysql" + "$ENV{PROGRAMFILES}/MySQL/*/lib" + "$ENV{SYSTEMDRIVE}/MySQL/*/lib" ) +mark_as_advanced( MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS ) + +if( MYSQL_INCLUDE_DIRS AND EXISTS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" ) + file( STRINGS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) + string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING "${MYSQL_VERSION_H}" ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set MYSQL_FOUND to TRUE if +# all listed variables are TRUE +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( MYSQL + REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS + VERSION_VAR MYSQL_VERSION_STRING ) diff --git a/3rdparty/cmake/FindPCRE.cmake b/3rdparty/cmake/FindPCRE.cmake new file mode 100644 index 000000000..cb4d9177b --- /dev/null +++ b/3rdparty/cmake/FindPCRE.cmake @@ -0,0 +1,35 @@ +# - Find pcre +# Find the native PCRE includes and library +# +# PCRE_INCLUDE_DIRS - where to find pcre.h +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + + +find_path( PCRE_INCLUDE_DIR pcre.h ) + +set( PCRE_NAMES pcre ) +find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} ) +mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR ) + +if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" ) + file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) + string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) + string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) + + set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" ) + set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" ) + set( PCRE_VERSION_MINOR "${PCRE_MINOR}" ) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if +# all listed variables are TRUE +include( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE + REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR + VERSION_VAR PCRE_VERSION_STRING ) + +if( PCRE_FOUND ) + set( PCRE_LIBRARIES ${PCRE_LIBRARY} ) + set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) +endif() diff --git a/3rdparty/mysql/CMakeLists.txt b/3rdparty/mysql/CMakeLists.txt index f4996907f..e85fd626d 100644 --- a/3rdparty/mysql/CMakeLists.txt +++ b/3rdparty/mysql/CMakeLists.txt @@ -44,7 +44,6 @@ endif( WIN32 ) message( STATUS "Detecting system MYSQL" ) unset( MYSQL_LIBRARIES CACHE ) unset( MYSQL_INCLUDE_DIRS CACHE ) -set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) find_package( MYSQL ) set( MYSQL_SYSTEM_LIBRARIES "${MYSQL_LIBRARIES}" CACHE PATH "system mysql libraries" ) diff --git a/3rdparty/mysql/FindMYSQL.cmake b/3rdparty/mysql/FindMYSQL.cmake deleted file mode 100644 index 0a07f3612..000000000 --- a/3rdparty/mysql/FindMYSQL.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# - Find mysqlclient -# Find the native MySQL includes and library -# -# MYSQL_INCLUDE_DIRS - where to find mysql.h, etc. -# MYSQL_LIBRARIES - mysqlclient library. -# MYSQL_FOUND - True if mysqlclient is found. -# - -find_path( MYSQL_INCLUDE_DIRS "mysql.h" - PATHS - "/usr/include/mysql" - "/usr/local/include/mysql" - "$ENV{PROGRAMFILES}/MySQL/*/include" - "$ENV{SYSTEMDRIVE}/MySQL/*/include" ) - -find_library( MYSQL_LIBRARIES - NAMES "mysqlclient" "mysqlclient_r" - PATHS - "/usr/lib/mysql" - "/usr/local/lib/mysql" - "$ENV{PROGRAMFILES}/MySQL/*/lib" - "$ENV{SYSTEMDRIVE}/MySQL/*/lib" ) -mark_as_advanced( MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS ) - -if( MYSQL_INCLUDE_DIRS AND EXISTS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" ) - file( STRINGS "${MYSQL_INCLUDE_DIRS}/mysql_version.h" MYSQL_VERSION_H REGEX "^#define[ \t]+MYSQL_SERVER_VERSION[ \t]+\"[^\"]+\".*$" ) - string( REGEX REPLACE "^.*MYSQL_SERVER_VERSION[ \t]+\"([^\"]+)\".*$" "\\1" MYSQL_VERSION_STRING "${MYSQL_VERSION_H}" ) -endif() - -# handle the QUIETLY and REQUIRED arguments and set MYSQL_FOUND to TRUE if -# all listed variables are TRUE -include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( MYSQL - REQUIRED_VARS MYSQL_LIBRARIES MYSQL_INCLUDE_DIRS - VERSION_VAR MYSQL_VERSION_STRING ) diff --git a/3rdparty/pcre/CMakeLists.txt b/3rdparty/pcre/CMakeLists.txt index 70448d40e..57465a46c 100644 --- a/3rdparty/pcre/CMakeLists.txt +++ b/3rdparty/pcre/CMakeLists.txt @@ -39,7 +39,6 @@ endif( WIN32 ) # system # message( STATUS "Detecting system PCRE" ) -set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} ) unset( PCRE_LIBRARIES CACHE ) unset( PCRE_INCLUDE_DIRS CACHE ) find_package( PCRE ) diff --git a/3rdparty/pcre/FindPCRE.cmake b/3rdparty/pcre/FindPCRE.cmake deleted file mode 100644 index cb4d9177b..000000000 --- a/3rdparty/pcre/FindPCRE.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# - Find pcre -# Find the native PCRE includes and library -# -# PCRE_INCLUDE_DIRS - where to find pcre.h -# PCRE_LIBRARIES - List of libraries when using pcre. -# PCRE_FOUND - True if pcre found. - - -find_path( PCRE_INCLUDE_DIR pcre.h ) - -set( PCRE_NAMES pcre ) -find_library( PCRE_LIBRARY NAMES ${PCRE_NAMES} ) -mark_as_advanced( PCRE_LIBRARY PCRE_INCLUDE_DIR ) - -if( PCRE_INCLUDE_DIR AND EXISTS "${PCRE_INCLUDE_DIR}/pcre.h" ) - file( STRINGS "${PCRE_INCLUDE_DIR}/pcre.h" PCRE_H REGEX "^#define[ \t]+PCRE_M[A-Z]+[ \t]+[0-9]+.*$" ) - string( REGEX REPLACE "^.*PCRE_MAJOR[ \t]+([0-9]+).*$" "\\1" PCRE_MAJOR "${PCRE_H}" ) - string( REGEX REPLACE "^.*PCRE_MINOR[ \t]+([0-9]+).*$" "\\1" PCRE_MINOR "${PCRE_H}" ) - - set( PCRE_VERSION_STRING "${PCRE_MAJOR}.${PCRE_MINOR}" ) - set( PCRE_VERSION_MAJOR "${PCRE_MAJOR}" ) - set( PCRE_VERSION_MINOR "${PCRE_MINOR}" ) -endif() - -# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if -# all listed variables are TRUE -include( FindPackageHandleStandardArgs ) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( PCRE - REQUIRED_VARS PCRE_LIBRARY PCRE_INCLUDE_DIR - VERSION_VAR PCRE_VERSION_STRING ) - -if( PCRE_FOUND ) - set( PCRE_LIBRARIES ${PCRE_LIBRARY} ) - set( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) -endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 523d445ef..1163ccddb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,5 @@ +##################################################################### +# # "Getting Started with CMake", a tutorial video by Eric Wing. # Part 1 of 6: http://www.youtube.com/watch?v=CLvZTyji_Uw # Part 2 of 6: http://www.youtube.com/watch?v=gUW-RrRQjEg @@ -11,8 +13,30 @@ # WITH_* : option to use an external package or not # ENABLE_* : option to use an internal feature/code or not # HAVE_* : internal variable indicating if we have and are using something -cmake_minimum_required( VERSION 2.8.4 ) +# +# Example (build in subdir 'build' and install to source dir): +# mkdir build +# cd build +# cmake -G"Unix Makefiles" -DINSTALL_TO_SOURCE:bool=ON .. +# make install +# cd .. +# rm -rf build +# +##################################################################### + + +#cmake_minimum_required( VERSION 2.8.4 ) +# Functional changes from 2.8.3 to 2.8.4: +# string(SUBSTRING) works with length -1 as "rest of string" +# changes to some CPack generators +# CYGWIN no longer defines WIN32 +# CMP0017: Prefer files from the CMake module directory when including from there. +set( CMAKE_LEGACY_CYGWIN_WIN32 0 ) +cmake_minimum_required( VERSION 2.8.3 ) project( eAthena ) +if( CYGWIN ) + unset( WIN32 ) +endif() # @@ -261,5 +285,4 @@ endif() # # subdirectories # -add_subdirectory( 3rdparty ) add_subdirectory( src ) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 4d512c8da..2840900ee 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -2,6 +2,7 @@ Date Added 2011/07/10 * Temporary fix for bugreport:4961 (unintended conversion from signed to unsigned). [FlavioJS] + * CMake: lowered required version to 2.8.3 and moved custom cmake modules to 3rdparty/cmake. 2011/07/09 * Added script command 'getmercinfo' for retrieving information about a mercenary of an online character. [Ai4rei] * CMake: added search for math library, made CPack existence optional, updated the search for mysqlclient and corrected misspelled variables (tested with FreeBSD-8.2-i386) [FlavioJS] -- cgit v1.2.3-60-g2f50