From 1cd298a004e19319fef1928e58d2e5b626e48027 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Verschelde?= Date: Sun, 20 Nov 2016 22:55:15 +0100 Subject: [PATCH] CMake: Drop LUGARU_INSTALL_PREFIX and clean CMakeLists In the cleanup: - Added section separators for clarity - Enforced lower case commands with no space before parenthesis --- .appveyor.yml | 4 ++-- .doozer.json | 4 ++-- .gitignore | 2 +- .gitlab-ci.yml | 8 +++---- CMakeLists.txt | 59 ++++++++++++++++++++++++++------------------------ COMPILING.md | 4 ++-- 6 files changed, 42 insertions(+), 39 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 8e693ad..b1d4b86 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -19,8 +19,8 @@ platform: before_build: - cd c:\projects\osslugaru\lugaru - set PATH=C:\Program Files (x86)\MSBuild\14.0\BIN;%PATH% - - if %PLATFORM% == Win32 cmake . -DCMAKE_BUILD_TYPE=Debug -DLUGARU_INSTALL_PREFIX=C:\projects\osslugaru\lugaru\msvc32-build - - if %PLATFORM% == Win64 cmake . -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug -DLUGARU_INSTALL_PREFIX=C:\projects\osslugaru\lugaru\msvc64-build + - if %PLATFORM% == Win32 cmake . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=C:\projects\osslugaru\lugaru\msvc32-build + - if %PLATFORM% == Win64 cmake . -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=C:\projects\osslugaru\lugaru\msvc64-build # Tell it what to build build: diff --git a/.doozer.json b/.doozer.json index 8f1baee..7cf1821 100644 --- a/.doozer.json +++ b/.doozer.json @@ -3,11 +3,11 @@ "centos7-x86_64": { "buildenv": "centos7-x86_64", "builddeps": ["/usr/bin/cmake3", "pkgconfig(libjpeg)", "pkgconfig(openal)", "pkgconfig(sdl2)", "pkgconfig(glu)", "pkgconfig(libpng)", "pkgconfig(zlib)", "pkgconfig(vorbis)", "pkgconfig(vorbisfile)", "pkgconfig(ogg)", "make"], - "buildcmd": ["cmake3 . -DLUGARU_INSTALL_PREFIX=/opt/osslugaru/lugaru/gcc-build", "make -j4"] + "buildcmd": ["cmake3 . -DCMAKE_INSTALL_PREFIX=/opt/osslugaru/lugaru/gcc-build", "make -j4"] }, "macosx": { "buildenv": "osx", - "buildcmd": ["cmake . -DLUGARU_INSTALL_PREFIX=/opt/osslugaru/lugaru/gcc-build", "make -j4"] + "buildcmd": ["cmake . -DCMAKE_INSTALL_PREFIX=/opt/osslugaru/lugaru/gcc-build", "make -j4"] } } } diff --git a/.gitignore b/.gitignore index 3999922..b06caa2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ run Xcode/build Xcode/*.xcodeproj/*.mode1v3 Xcode/*.xcodeproj/*.pbxuser -build +build* *~ .*.swp lugaru* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1846e12..27671e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ build_gcc: - dnf --quiet --assumeyes install gcc gcc-c++ - export CC=gcc; export CXX=g++ - mkdir -p x86_64-linux-gnu-gcc gcc-build; cd x86_64-linux-gnu-gcc - - cmake .. -DLUGARU_INSTALL_PREFIX=/builds/osslugaru/lugaru/gcc-build + - cmake .. -DCMAKE_INSTALL_PREFIX=/builds/osslugaru/lugaru/gcc-build - make -j4; make install artifacts: expire_in: 7d @@ -29,7 +29,7 @@ build_clang: - dnf --quiet --assumeyes install clang - export CC=clang; export CXX=clang++ - mkdir -p x86_64-linux-gnu-clang clang-build; cd x86_64-linux-gnu-clang - - cmake .. -DLUGARU_INSTALL_PREFIX=/builds/osslugaru/lugaru/clang-build + - cmake .. -DCMAKE_INSTALL_PREFIX=/builds/osslugaru/lugaru/clang-build - make -j4; make install artifacts: expire_in: 7d @@ -47,7 +47,7 @@ build_mingw32: - export PKG_CONFIG_LIBDIR="/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/i686-w64-mingw32/sys-root/mingw/share/pkgconfig" - export PATH=/usr/i686-w64-mingw32/bin:$PATH - mkdir -p i686-w64-mingw32 mingw32-build; cd i686-w64-mingw32 - - cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake -DLUGARU_INSTALL_PREFIX=/builds/osslugaru/lugaru/mingw32-build + - cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=/builds/osslugaru/lugaru/mingw32-build - make -j4; make install artifacts: expire_in: 7d @@ -65,7 +65,7 @@ build_mingw64: - export PKG_CONFIG_LIBDIR="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/x86_64-w64-mingw32/sys-root/mingw/share/pkgconfig" - export PATH=/usr/x86_64-w64-mingw32/bin:$PATH - mkdir -p x86_64-w64-mingw32 mingw64-build; cd x86_64-w64-mingw32 - - cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw64.cmake -DLUGARU_INSTALL_PREFIX=/builds/osslugaru/lugaru/mingw64-build + - cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw64.cmake -DCMAKE_INSTALL_PREFIX=/builds/osslugaru/lugaru/mingw64-build - make -j4; make install artifacts: expire_in: 7d diff --git a/CMakeLists.txt b/CMakeLists.txt index 522b22f..29f70eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,27 +3,20 @@ project(lugaru) cmake_minimum_required(VERSION 3.5) cmake_policy(SET CMP0004 OLD) -INCLUDE(FindPkgConfig) +include(FindPkgConfig) set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/Source") + +### CMake config + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 --std=c++11") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-parentheses -g -pg --std=c++11") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-parentheses -O2 -std=c++11") -if(NOT LUGARU_INSTALL_PREFIX) - if(WIN32) - set(LUGARU_INSTALL_PREFIX "C:/Lugaru" CACHE PATH - "LUGARU_INSTALL_PREFIX: Install path prefix, prepended onto install directories." - FORCE) - else(WIN32) - set(LUGARU_INSTALL_PREFIX "/usr/local/lugaru" CACHE PATH - "CMAKE_INSTALL_PREFIX: Install path prefix, prepended onto install directories." - FORCE) - endif(WIN32) -endif(NOT LUGARU_INSTALL_PREFIX) - -set(CMAKE_INSTALL_PREFIX "${LUGARU_INSTALL_PREFIX}" CACHE INTERNAL "Prefix prepended to install directories" FORCE) +if(NOT CMAKE_INSTALL_PREFIX AND WIN32) + set(CMAKE_INSTALL_PREFIX "C:/Lugaru") +endif(NOT CMAKE_INSTALL_PREFIX AND WIN32) if(APPLE) set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX") @@ -35,6 +28,9 @@ endif(APPLE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") + +### Sources + set(LUGARU_SRCS ${SRCDIR}/Frustum.cpp ${SRCDIR}/Account.cpp @@ -115,15 +111,15 @@ if(UNIX) endif(UNIX) if(WIN32) - ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj - COMMAND ${CMAKE_RC_COMPILER} - -I${SRCDIR}/win-res - -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj - -i${SRCDIR}/win-res/Lugaru.rc - DEPENDS ${SRCDIR}/win-res/Lugaru.rc + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj + COMMAND ${CMAKE_RC_COMPILER} + -I${SRCDIR}/win-res + -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj + -i${SRCDIR}/win-res/Lugaru.rc + DEPENDS ${SRCDIR}/win-res/Lugaru.rc ) - # !!! FIXME: get rid of this. + # FIXME: get rid of this. set(LUGARU_SRCS ${LUGARU_SRCS} ${SRCDIR}/WinDefs.cpp) @@ -134,21 +130,22 @@ if(WIN32) ${SRCDIR}/win-res/resource.h) endif(WIN32) -if (APPLE) +if(APPLE) set(PLATFORM_LIBS "-framework Carbon -framework Cocoa -framework OpenGL -framework OpenAL") -endif (APPLE) +endif(APPLE) -# Deal with dependencies... + +### Dependencies find_package(OpenGL REQUIRED) # Windows is funky about OpenAL detection -if (WIN32) +if(WIN32) pkg_check_modules(OPENAL openal REQUIRED) set(OPENAL_LIBRARY ${OPENAL_LIBRARIES}) -else (WIN32) +else(WIN32) find_package(OpenAL REQUIRED) -endif() +endif(WIN32) find_package(sdl2 REQUIRED) find_package(PNG REQUIRED) @@ -171,6 +168,8 @@ include_directories( set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS}) +### Definitions + if(WIN32) add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} lugaru_resource.obj) else(WIN32) @@ -182,13 +181,16 @@ target_link_libraries(lugaru ${LUGARU_LIBS}) if(WIN32) add_definitions(-DUSE_OPENAL=1 -DUSE_SDL=1 -DBinIO_STDINT_HEADER=) if(MINGW) + # An alternative would be to use _WIN32 consistently instead of WIN32 add_definitions(-DWIN32) endif(MINGW) else(WIN32) add_definitions(-DPLATFORM_LINUX=1 -DPLATFORM_UNIX=1 -DUSE_OPENAL=1 -DUSE_SDL=1 -DBinIO_STDINT_HEADER=) endif(WIN32) -# Install target + +### Installation + if(APPLE) set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app") set(APPS_BIN "${APPS_ROOT}/Contents/MacOS") @@ -198,6 +200,7 @@ endif(APPLE) if(WIN32) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX}) if(MINGW) + # Based off Mageia/Fedora MinGW toolchain, might not work on other distros or Windows set(LIBGCC_S libgcc_s_sjlj-1.dll) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") # MinGW64 set(LIBGCC_S libgcc_s_seh-1.dll) diff --git a/COMPILING.md b/COMPILING.md index 745cc17..5b9ab9e 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -72,7 +72,7 @@ export PATH=/usr/i686-w64-mingw32/bin:$PATH Then build: ``` mkdir build-mingw32 && cd build-mingw32 -cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake -DLUGARU_INSTALL_PREFIX=install +cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=install make make install ``` @@ -90,7 +90,7 @@ export PATH=/usr/x86_64-w64-mingw32/bin:$PATH ``` ``` mkdir build-mingw64 && cd build-mingw64 -cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw64.cmake -DLUGARU_INSTALL_PREFIX=install +cmake .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/mingw/toolchain-mingw64.cmake -DCMAKE_INSTALL_PREFIX=install make make install ``` -- 2.39.5