From 69de38bf1db715a2fbb0c3c82987a66094ec0ad7 Mon Sep 17 00:00:00 2001 From: ddaroo Date: Sun, 15 Jul 2012 16:05:41 +0000 Subject: [PATCH] Tweaks for cmake build system: data dir definitions, flags for clang (not tested), missing CQuestLog.cpp file for the client, naming convention of few binaries same for autotools and cmake --- AI/EmptyAI/CMakeLists.txt | 2 +- AI/FuzzyLite/CMakeLists.txt | 2 +- AI/StupidAI/CMakeLists.txt | 4 ++-- AI/VCAI/CMakeLists.txt | 2 +- CMakeLists.txt | 27 +++++++++++++++++++++++++-- Scripting/ERM/CMakeLists.txt | 8 ++++---- client/CMakeLists.txt | 9 +++++---- lib/CMakeLists.txt | 6 +++--- server/CMakeLists.txt | 8 ++++---- 9 files changed, 46 insertions(+), 22 deletions(-) diff --git a/AI/EmptyAI/CMakeLists.txt b/AI/EmptyAI/CMakeLists.txt index 45369c2c9..c6d49464c 100644 --- a/AI/EmptyAI/CMakeLists.txt +++ b/AI/EmptyAI/CMakeLists.txt @@ -9,4 +9,4 @@ set(emptyAI_SRCS ) add_library(emptyAI SHARED ${emptyAI_SRCS}) -target_link_libraries(emptyAI vcmi_lib) +target_link_libraries(emptyAI vcmi) diff --git a/AI/FuzzyLite/CMakeLists.txt b/AI/FuzzyLite/CMakeLists.txt index 9c2fd1afa..be067a380 100644 --- a/AI/FuzzyLite/CMakeLists.txt +++ b/AI/FuzzyLite/CMakeLists.txt @@ -47,5 +47,5 @@ set(FuzzyLite_lib_SRCS add_library(FuzzyLite_lib STATIC ${FuzzyLite_lib_SRCS}) IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - SET_TARGET_PROPERTIES(FuzzyLite_lib PROPERTIES COMPILE_FLAGS "-fPIC") + SET_TARGET_PROPERTIES(FuzzyLite_lib PROPERTIES COMPILE_FLAGS "-fPIC") ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") \ No newline at end of file diff --git a/AI/StupidAI/CMakeLists.txt b/AI/StupidAI/CMakeLists.txt index d8d323687..320812718 100644 --- a/AI/StupidAI/CMakeLists.txt +++ b/AI/StupidAI/CMakeLists.txt @@ -8,5 +8,5 @@ set(stupidAI_SRCS main.cpp ) -add_library(stupidAI SHARED ${stupidAI_SRCS}) -target_link_libraries(stupidAI vcmi_lib) +add_library(StupidAI SHARED ${stupidAI_SRCS}) +target_link_libraries(StupidAI vcmi) diff --git a/AI/VCAI/CMakeLists.txt b/AI/VCAI/CMakeLists.txt index d937d488f..1641e8efd 100644 --- a/AI/VCAI/CMakeLists.txt +++ b/AI/VCAI/CMakeLists.txt @@ -10,4 +10,4 @@ set(VCAI_SRCS ) add_library(VCAI SHARED ${VCAI_SRCS}) -target_link_libraries(VCAI FuzzyLite_lib vcmi_lib) \ No newline at end of file +target_link_libraries(VCAI FuzzyLite_lib vcmi) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eff2644a..3a6a86af0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ project(vcmi) cmake_minimum_required(VERSION 2.6) +#needed? +INCLUDE(CheckLibraryExists) + # where to look for cmake modules set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) @@ -14,10 +17,30 @@ find_package(SDL_ttf REQUIRED) find_package(ZLIB REQUIRED) find_package(FFMPEG_swscale REQUIRED) -if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "-std=c++0x -Wall -Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized") +#check if some platform-specific libraries are needed for linking client and server +CHECK_LIBRARY_EXISTS(rt shm_open "" HAVE_RT_LIB) +if(HAVE_RT_LIB) + set(RT_LIB -lrt) endif() +CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DL_LIB) +if(HAVE_DL_LIB) + set(DL_LIB -ldl) +endif() + +if(CMAKE_CXX_COMPILER MATCHES ".*clang") + set(CMAKE_COMPILER_IS_CLANGXX 1) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) + set(CMAKE_CXX_FLAGS "-std=c++0x -Wall -Wextra -Wpointer-arith -Wno-switch -Wno-sign-compare -Wno-unused-parameter -Wno-overloaded-virtual") +endif() + +#define required constants +add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share") +add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/lib/vcmi") +add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/bin") + add_subdirectory(lib) add_subdirectory(client) add_subdirectory(server) diff --git a/Scripting/ERM/CMakeLists.txt b/Scripting/ERM/CMakeLists.txt index 30bfcac2d..8a157d314 100644 --- a/Scripting/ERM/CMakeLists.txt +++ b/Scripting/ERM/CMakeLists.txt @@ -1,13 +1,13 @@ -project(vcmi_ERM) +project(vcmiERM) cmake_minimum_required(VERSION 2.6) include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIRECTORY}) set(lib_SRCS - ERMInterpreter.cpp + ERMInterpreter.cpp ERMParser.cpp ERMScriptModule.cpp ) -add_library(vcmi_ERM_lib SHARED ${lib_SRCS}) -target_link_libraries(vcmi_ERM_lib ${Boost_LIBRARIES}) +add_library(vcmiERM SHARED ${lib_SRCS}) +target_link_libraries(vcmiERM ${Boost_LIBRARIES}) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index edc24b3e8..30ed785d0 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -1,4 +1,4 @@ -project(vcmi_client) +project(vcmiclient) cmake_minimum_required(VERSION 2.6) include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) @@ -39,6 +39,7 @@ set(client_SRCS CSndHandler.cpp CSpellWindow.cpp CVideoHandler.cpp + CQuestLog.cpp Graphics.cpp GUIClasses.cpp mapHandler.cpp @@ -47,9 +48,9 @@ set(client_SRCS ) IF(UNIX) - add_executable(vcmi_client ${client_SRCS}) + add_executable(vcmiclient ${client_SRCS}) ELSEIF(WIN32) - add_executable(vcmi_client WIN32 ${client_SRCS}) + add_executable(vcmiclient WIN32 ${client_SRCS}) ENDIF() -target_link_libraries(vcmi_client vcmi_lib ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES}) +target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES}) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 75665a216..61047588d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -project(vcmi_lib) +project(libvcmi) cmake_minimum_required(VERSION 2.6) include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIRECTORY}) @@ -38,5 +38,5 @@ set(lib_SRCS VCMI_Lib.cpp ) -add_library(vcmi_lib SHARED ${lib_SRCS}) -target_link_libraries(vcmi_lib ${Boost_LIBRARIES} ${SDL_LIBRARY} ${ZLIB_LIBRARIES}) +add_library(vcmi SHARED ${lib_SRCS}) +target_link_libraries(vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${ZLIB_LIBRARIES}) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 972d152ec..1a4390fc9 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -1,4 +1,4 @@ -project(vcmi_server) +project(vcmiserver) cmake_minimum_required(VERSION 2.6) include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib) @@ -11,9 +11,9 @@ set(server_SRCS ) IF(UNIX) - add_executable(vcmi_server ${server_SRCS}) + add_executable(vcmiserver ${server_SRCS}) ELSEIF(WIN32) - add_executable(vcmi_server WIN32 ${server_SRCS}) + add_executable(vcmiserver WIN32 ${server_SRCS}) ENDIF() -target_link_libraries(vcmi_server vcmi_lib ${Boost_LIBRARIES}) +target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES})