Fix cmake (#2554)
* Fix cmake Thanks to @secretdataz for help. (cherry-picked from refactor)
This commit is contained in:
@@ -28,20 +28,39 @@
|
||||
# changes to some CPack generators
|
||||
# CYGWIN no longer defines WIN32
|
||||
# CMP0017: Prefer files from the CMake module directory when including from there.
|
||||
# Update to 3.1 for CMAKE_CXX_STANDARD cross support definition
|
||||
set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
|
||||
cmake_minimum_required( VERSION 2.8.8 )
|
||||
project( rAthena C )
|
||||
cmake_minimum_required( VERSION 3.1 )
|
||||
project( rAthena )
|
||||
if( CYGWIN )
|
||||
unset( WIN32 )
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD 11) # C++11...
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
|
||||
#set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++11
|
||||
|
||||
#actually this might be misleading for arm...
|
||||
if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
|
||||
set(architecture x86)
|
||||
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
set(architecture x64)
|
||||
else()
|
||||
message( FATAL_ERROR "unexpected architecture (CMAKE_SIZEOF_VOID_P is ${CMAKE_SIZEOF_VOID_P})" )
|
||||
endif()
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${suffixInstallStr})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
set(CMAKE_C_CREATE_SHARED_LIBRARY)
|
||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
set(CMAKE_RELEASE_POSTFIX "r")
|
||||
#
|
||||
# Prevent building in the source directory by default
|
||||
#
|
||||
option( ALLOW_SAME_DIRECTORY "Allow CMake to build in the source directory." OFF )
|
||||
if( ALLOW_SAME_DIRECTORY )
|
||||
elseif( "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
option( ALLOW_SAME_DIRECTORY "Allow CMake to build in the source directory." OFF )
|
||||
message( FATAL_ERROR
|
||||
"Do not use the source directory to build your files, instead delete CMakeCache.txt, create a separate folder and build there.\n"
|
||||
"Example: (build in subdir 'build' and install to source dir)\n"
|
||||
@@ -105,47 +124,12 @@ if(GIT_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Find svnversion
|
||||
#
|
||||
message( STATUS "Detecting svnversion" )
|
||||
find_program( SVNVERSION_EXECUTABLE svnversion )
|
||||
mark_as_advanced( SVNVERSION_EXECUTABLE )
|
||||
if( SVNVERSION_EXECUTABLE )
|
||||
message( STATUS "Found svnversion: ${SVNVERSION_EXECUTABLE}" )
|
||||
endif()
|
||||
message( STATUS "Detecting svnversion - done" )
|
||||
#
|
||||
# Find Subversion
|
||||
#
|
||||
message( STATUS "Detecting Subversion" )
|
||||
find_package( Subversion )
|
||||
message( STATUS "Detecting Subversion - done" )
|
||||
#
|
||||
# SVNVERSION
|
||||
#
|
||||
if( SVNVERSION_EXECUTABLE )
|
||||
message( STATUS "Getting svn version" )
|
||||
execute_process( COMMAND ${SVNVERSION_EXECUTABLE} ${PROJECT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE SVNVERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE )
|
||||
if( SVNVERSION MATCHES "^Unversioned" )
|
||||
set( SVNVERSION )
|
||||
endif()
|
||||
string( REGEX REPLACE "[^1234567890MSexported]" "_" SVNVERSION "${SVNVERSION}" )
|
||||
message( STATUS "Found SVNversion: ${SVNVERSION}" )
|
||||
message( STATUS "Getting svn version - done" )
|
||||
endif()
|
||||
if( Subversion_FOUND AND SVNVERSION )
|
||||
message( STATUS "Getting svn branch" )
|
||||
Subversion_WC_INFO( ${PROJECT_SOURCE_DIR} rAthena )
|
||||
if( rAthena_WC_URL )
|
||||
string( REGEX MATCH "[^/]+$" BRANCH ${rAthena_WC_URL} )
|
||||
set( SVNVERSION "${BRANCH}-${SVNVERSION}" )
|
||||
message( STATUS "Found branch: ${BRANCH}" )
|
||||
endif()
|
||||
message( STATUS "Getting svn branch - done" )
|
||||
endif()
|
||||
include(GetGitVersion)
|
||||
get_git_version()
|
||||
|
||||
#include(GetSvnVersion)
|
||||
#get_svn_version(SVN_VERSION)
|
||||
#message( STATUS "SVN_VERSION: ${SVN_VERSION}" )
|
||||
|
||||
|
||||
#
|
||||
@@ -198,12 +182,12 @@ endif()
|
||||
#
|
||||
if( NOT MSVC )
|
||||
message( STATUS "Detecting networking library (socket/nsl/ws2_32)" )
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
find_function_library( bind FUNCTION_BIND_LIBRARIES socket ws2_32 )
|
||||
if( FUNCTION_BIND_LIBRARIES )
|
||||
message( STATUS "Adding global library: ${FUNCTION_BIND_LIBRARIES}" )
|
||||
set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_BIND_LIBRARIES} )
|
||||
endif()
|
||||
#set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
#find_function_library( bind FUNCTION_BIND_LIBRARIES socket ws2_32 )
|
||||
#if( FUNCTION_BIND_LIBRARIES )
|
||||
# message( STATUS "Adding global library: ${FUNCTION_BIND_LIBRARIES}" )
|
||||
# set_property( CACHE GLOBAL_LIBRARIES PROPERTY VALUE ${GLOBAL_LIBRARIES} ${FUNCTION_BIND_LIBRARIES} )
|
||||
#endif()
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
find_function_library( gethostbyname FUNCTION_GETHOSTBYNAME_LIBRARIES nsl )
|
||||
if( FUNCTION_GETHOSTBYNAME_LIBRARIES )
|
||||
@@ -590,11 +574,7 @@ add_subdirectory( src )
|
||||
#####################################################################
|
||||
# final checks and warnings
|
||||
#
|
||||
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||
message( WARNING "64bit should work, but is not recommended." )
|
||||
elseif( NOT CMAKE_SIZEOF_VOID_P EQUAL 4 )
|
||||
message( FATAL_ERROR "unexpected architecture (CMAKE_SIZEOF_VOID_P is ${CMAKE_SIZEOF_VOID_P})" )
|
||||
endif()
|
||||
|
||||
list( LENGTH TARGET_LIST _LEN )
|
||||
if( _LEN EQUAL 0 )
|
||||
message( FATAL_ERROR "no targets available" )
|
||||
|
||||
Reference in New Issue
Block a user