From 04a7a0d7e2aa92a0f5c9c05732cf5ef12732ff11 Mon Sep 17 00:00:00 2001 From: Iss Mneur Date: Sat, 8 Oct 2016 13:35:04 -0600 Subject: [PATCH] Setup the submodules automaticilly Use system libraries on linux rather than included --- .gitmodules | 4 ++-- 3rdparty | 2 +- CMakeLists.txt | 40 ++++++++++++++++++++------------ cmake/setup_submodules.cmake | 14 +++++++++++ code/apis/resolution_manager.cpp | 4 ---- 5 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 cmake/setup_submodules.cmake diff --git a/.gitmodules b/.gitmodules index be75768..d8dff54 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "3rdparty"] path = 3rdparty - url = git@github.com:wxLauncher/wxlauncher-3rdparty.git + url = https://github.com/wxLauncher/wxlauncher-3rdparty.git [submodule "cmake/modules/sdl2-cmake-scripts"] path = cmake/modules/sdl2-cmake-scripts - url = ssh://git@github.com/IssMneur/sdl2-cmake-scripts + url = https://github.com/IssMneur/sdl2-cmake-scripts.git diff --git a/3rdparty b/3rdparty index 6cf84dd..c7c7c84 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit 6cf84dd56ce9d19a33248423a996a1b2b337363f +Subproject commit c7c7c849c5d135d91075bde69f272e2f7e74a81b diff --git a/CMakeLists.txt b/CMakeLists.txt index 21182bc..ac46e51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,28 +20,32 @@ if(NOT GIT_EXECUTABLE) " - Call cmake with -DGIT_EXECUTABLE=") endif() -# Special source directorys +if(NOT(DEFINED IS_WIN32 OR DEFINED IS_LINUX OR DEFINED IS_APPLE)) + if(WIN32) + set(IS_WIN32 TRUE) + set(USE_3RDPARTY_DEFAULT ON) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(IS_APPLE TRUE) + set(USE_3RDPARTY_DEFAULT ON) + else() + set(IS_LINUX TRUE) + set(USE_3RDPARTY_DEFAULT OFF) + endif() +endif() + +# Special source directories set(LAUNCHER_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/cmake) +include(${LAUNCHER_CMAKE_SOURCE_DIR}/setup_submodules.cmake) include(${LAUNCHER_CMAKE_SOURCE_DIR}/modules/modules.cmake) list(INSERT CMAKE_MODULE_PATH 0 "${LAUNCHER_CMAKE_SOURCE_DIR}/include") set(3RD_PARTY_SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty) - include(${LAUNCHER_CMAKE_SOURCE_DIR}/GetVersionFromGitTag.cmake) message("--- Configuring wxLauncher ${wxlauncher_VERSION_STRING_FULL}") -if(NOT(DEFINED IS_WIN32 OR DEFINED IS_LINUX OR DEFINED IS_APPLE)) - if(WIN32) - set(IS_WIN32 TRUE) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(IS_APPLE TRUE) - else() - set(IS_LINUX TRUE) - endif() -endif() - -option(USE_3RDPARTY "Use the libraries in the 3rd party directory" ON) +option(USE_3RDPARTY "Use the libraries in the 3rd party directory" + ${USE_3RDPARTY_DEFAULT}) if(USE_3RDPARTY) message("--- Using 3rd party source directory") execute_process(COMMAND ${CMAKE_COMMAND} @@ -363,8 +367,14 @@ add_executable(wxlauncher WIN32 MACOSX_BUNDLE ${RESOURCE_FILES} ${CODE_FILES} ) +# C++11 is required for wxWidgets 3.0 and wxLauncher's new code +# (the auto_type specifically) if (COMMAND target_compile_features) - target_compile_features(wxlauncher PRIVATE cxx_auto_type) # Enable C++11 because it is required for wxWidgets 3.0 + # target_compile_features added in CMake 3.1 + target_compile_features(wxlauncher PRIVATE cxx_auto_type) +else() + set_property(TARGET wxlauncher APPEND_STRING + PROPERTY COMPILE_FLAGS "-std=c++11") endif() set_target_properties(wxlauncher @@ -388,7 +398,7 @@ foreach(temp_file ${helpmaker_temp_files}) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${temp_file}) endforeach(temp_file) -target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES}) +target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARY}) # adapted from http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_apply_resources_on_Mac_OS_X_automatically.3F # copies necessary resources (and frameworks, if needed) to .app bundle diff --git a/cmake/setup_submodules.cmake b/cmake/setup_submodules.cmake new file mode 100644 index 0000000..c36665d --- /dev/null +++ b/cmake/setup_submodules.cmake @@ -0,0 +1,14 @@ +set(STATUS) +execute_process(COMMAND ${GIT_EXECUTABLE} submodule init + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE STATUS) +if(STATUS) + message(FATAL_ERROR "Failed to init submodules: ${STATUS}") +endif() +set(STATUS) +execute_process(COMMAND ${GIT_EXECUTABLE} submodule update + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE STATUS) +if(STATUS) + message(FATAL_ERROR "Failed to update submodules: ${STATUS}") +endif() diff --git a/code/apis/resolution_manager.cpp b/code/apis/resolution_manager.cpp index e7fea09..6164ace 100644 --- a/code/apis/resolution_manager.cpp +++ b/code/apis/resolution_manager.cpp @@ -254,10 +254,6 @@ void EnumerateGraphicsModes_sdl( #endif } -#if !HAS_SDL && !defined(WIN32) -#error No implementation of EnumerateGraphicsModes available -#endif - /** Get available graphics modes for API and return them sorted */ void ResolutionMan::EnumerateGraphicsModes( ApiType type, ResolutionArray& out_modes,