Commit 3f9c08ca authored by gerstrong@gmail.com's avatar gerstrong@gmail.com

Many CMakeLists improvements regarding detection of CURL, Zlib and Python3

parent b1b0e0e2
# CMake file for development of Commander Genius (taken from OLX)
# This CMake file is used under Linux normally.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
Project(CommanderGenius)
......@@ -9,7 +9,10 @@ set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
# Use COmpile TIme REducer
include(cotire)
include(FindSDL2_mixer)
if(USE_SDL2S)
include(FindSDL2_mixer)
endif()
option(USE_PYTHON3 "Use Python3 scripts" yes)
......
# CMake file for development of Commander Genius (taken from OLX)
# This CMake file is used under Linux normally.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)
Project(GsKit)
OPTION(USE_SDL2 "SDL2 support" Yes)
option(USE_PYTHON3 "Use Python3 scripts" yes)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
......@@ -76,14 +80,21 @@ endif(USE_SDL2)
# Use python3 for AI scripting and more!
IF(USE_PYTHON3)
# Look for Python (Version 3.0 or later is required)
FIND_PACKAGE(PythonLibs)
ADD_DEFINITIONS(-DUSE_PYTHON3=1)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
LINK_LIBRARIES(${PYTHON_LIBRARIES})
FIND_PACKAGE(Python3 COMPONENTS Interpreter Development)
if(Python3_FOUND)
ADD_DEFINITIONS(-DUSE_PYTHON3=1)
INCLUDE_DIRECTORIES(${Python3_INCLUDE_DIRS})
LINK_LIBRARIES(${Python3_LIBRARIES})
message(STATUS "Python3_LIBRARIES = ${Python3_LIBRARIES}")
message(STATUS "Python3_INCLUDE_DIRS = ${Python3_INCLUDE_DIRS}")
else()
message(FATAL_ERROR "Python3 not found!")
endif()
ENDIF()
Project(GsKit)
# From this point files are globbed for compilation and project setup
file(GLOB_RECURSE ALL_SRCS_GSKIT_BASE *.c* *.h*)
......@@ -106,7 +117,8 @@ endif()
IF(OPENGL)
# OpenGL Parsing
find_package(OpenGL REQUIRED)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
ADD_DEFINITIONS(-DGL)
ADD_DEFINITIONS(-DUSE_OPENGL)
......
......@@ -46,6 +46,7 @@ CInput::CInput()
for(size_t c=1 ; c<= NUM_INPUTS ; c++)
resetControls(c);
memset(&Event,0,sizeof(Event));
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
loadControlconfig(); // we want to have the default settings in all cases
startJoyDriver(); // not for iPhone for now, could cause trouble (unwanted input events)
......
......@@ -45,19 +45,7 @@
# define __GNUC_PREREQ(maj, min) (0)
# endif
// include hash_set support
# if !defined(STLPORT)
# if defined(__GNUC__) && __GNUC_PREREQ(4,3) || defined(ANDROID)
# include <tr1/unordered_set>
# define hash_set std::tr1::unordered_set
# else
# include <ext/hash_set>
using __gnu_cxx::hash_set;
# endif
# else // STLPORT
# include <hash_set>
using std::hash_set;
# endif
#include <unordered_set>
// for getpwduid
# include <pwd.h>
......@@ -308,7 +296,7 @@ struct strcasecomparer {
}
};
typedef hash_set<std::string, simple_reversestring_hasher, strcasecomparer> exactfilenamecache_t;
typedef std::unordered_set<std::string, simple_reversestring_hasher, strcasecomparer> exactfilenamecache_t;
struct ExactFilenameCache {
exactfilenamecache_t cache;
Mutex mutex;
......@@ -802,7 +790,7 @@ std::string GetHomeDir()
#else
char* home = getenv("HOME");
#endif
if(home == NULL || home[0] == '\0') {
if(home == nullptr || home[0] == '\0') {
passwd* userinfo = getpwuid(getuid());
if(userinfo)
return userinfo->pw_dir;
......
......@@ -46,12 +46,20 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=cast-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=cast-align")
# Use python3 for AI scripting and more!
# Use python3 for AI scripting and more!
IF(USE_PYTHON3)
FIND_PACKAGE(PythonLibs)
ADD_DEFINITIONS(-DUSE_PYTHON3=1)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
LINK_LIBRARIES(${PYTHON_LIBRARIES})
# Look for Python (Version 3.0 or later is required)
FIND_PACKAGE(Python3 COMPONENTS Interpreter Development)
if(Python3_FOUND)
ADD_DEFINITIONS(-DUSE_PYTHON3=1)
INCLUDE_DIRECTORIES(${Python3_INCLUDE_DIRS})
LINK_LIBRARIES(${Python3_LIBRARIES})
message(STATUS "Python3_LIBRARIES = ${Python3_LIBRARIES}")
message(STATUS "Python3_INCLUDE_DIRS = ${Python3_INCLUDE_DIRS}")
else()
message(FATAL_ERROR " Python3 not found!")
endif()
ENDIF()
......@@ -117,27 +125,6 @@ ELSE(Boost_FOUND)
ENDIF(Boost_FOUND)
find_package( ZLIB REQUIRED )
if ( ZLIB_FOUND )
include_directories( ${ZLIB_INCLUDE_DIRS} )
endif( ZLIB_FOUND )
if(DOWNLOADER)
FIND_PACKAGE(CURL)
IF(CURL_FOUND)
if(WIN32)
ADD_DEFINITIONS(-DCURL_STATICLIB)
endif()
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
ELSE(CURL_FOUND)
MESSAGE(FATAL_ERROR "Could not find the CURL library and development files." )
ENDIF(CURL_FOUND)
endif()
if(USE_SDL2)
......@@ -229,9 +216,6 @@ target_link_libraries (CGeniusExe GsKit)
# Link our SDL Extensions
target_link_libraries(CGeniusExe sdl_extensions_audio sdl_extensions_sys)
# Link zlib
target_link_libraries( CGeniusExe ${ZLIB_LIBRARIES} )
if(USE_SDL2)
message(STATUS "SDL2_LIBRARY = ${SDL2_LIBRARY}")
......@@ -245,11 +229,6 @@ endif(USE_SDL2)
IF(CURL_FOUND)
TARGET_LINK_LIBRARIES(CGeniusExe ${CURL_LIBRARIES})
ENDIF(CURL_FOUND)
# The Windows Version has an icon in the executable
IF(WIN32)
SET_TARGET_PROPERTIES(CGeniusExe PROPERTIES OUTPUT_NAME "CGenius")
......
......@@ -11,11 +11,26 @@ add_subdirectory(refkeen)
add_subdirectory(unzip)
if(DOWNLOADER)
add_definitions(-DDOWNLOADER)
FIND_PACKAGE(CURL)
IF(CURL_FOUND)
if(WIN32)
ADD_DEFINITIONS(-DCURL_STATICLIB)
endif()
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "Could not find the CURL library and development files." )
ENDIF()
endif()
set(CXXSRC CGameLauncher.cpp
downloadgui.cpp
gamedownloader.cpp)
......@@ -36,3 +51,4 @@ target_link_libraries(engine
cg_dialog
unzip)
TARGET_LINK_LIBRARIES(engine ${CURL_LIBRARIES})
find_package( ZLIB REQUIRED )
if ( ZLIB_FOUND )
include_directories( ${ZLIB_INCLUDE_DIRS} )
else ( ZLIB_FOUND )
Message(FATAL_ERROR "Zlib development packages not found!")
endif( ZLIB_FOUND )
set(CXXSRC
miniunz.c
ioapi.c
......@@ -11,5 +21,7 @@ set(HSRC
add_library(unzip ${CXXSRC} ${HSRC})
target_link_libraries(unzip z)
# Link zlib
target_link_libraries( unzip ${ZLIB_LIBRARIES} )
  • Ubuntu 18.04

    CMake Warning at GsKit/CMakeLists.txt:83 (FIND_PACKAGE):
      By not providing "FindPython3.cmake" in CMAKE_MODULE_PATH this project has
      asked CMake to find a package configuration file provided by "Python3", but
      CMake did not find one.
    
      Could not find a package configuration file provided by "Python3" with any
      of the following names:
    
        Python3Config.cmake
        python3-config.cmake

    Minimum required cmake is 3.10 but module FindPython3.cmake wasn't introduced until 3.12. https://gitlab.kitware.com/cmake/cmake/blob/v3.12.0/Modules/FindPython3.cmake

    Copied the following files from cmake 3.13.1 Download | CMake into my project and now I can build:

    cgenius/CMake/CMakeFindFrameworks.cmake
    cgenius/CMake/FindPackageHandleStandardArgs.cmake
    cgenius/CMake/FindPackageMessage.cmake
    cgenius/CMake/FindPython3.cmake
    cgenius/CMake/FindPython/Support.cmake
    cgenius/CMake/SelectLibraryConfigurations.cmake
    Edited by noa body
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment