]> git.jsancho.org Git - lugaru.git/commitdiff
CMake: Drop LUGARU_INSTALL_PREFIX and clean CMakeLists
authorRémi Verschelde <rverschelde@gmail.com>
Sun, 20 Nov 2016 21:55:15 +0000 (22:55 +0100)
committerRémi Verschelde <rverschelde@gmail.com>
Sun, 20 Nov 2016 22:19:02 +0000 (23:19 +0100)
In the cleanup:
- Added section separators for clarity
- Enforced lower case commands with no space before parenthesis

.appveyor.yml
.doozer.json
.gitignore
.gitlab-ci.yml
CMakeLists.txt
COMPILING.md

index 8e693ad2a49744aeb845aa57c527240f07f10ce0..b1d4b8605a200f3e56ebba3d110c310392b0fd16 100644 (file)
@@ -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:
index 8f1baee2a5453230a68c0daa6fcd1ac3528ff154..7cf1821ee6887c55c82fa697aca3fb004eb6eb47 100644 (file)
@@ -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"]
     }
   }
 }
index 399992262cf1d9244421b6dcfe6f7802d8a85705..b06caa23878545817984e185c53757078cd80618 100644 (file)
@@ -3,7 +3,7 @@ run
 Xcode/build
 Xcode/*.xcodeproj/*.mode1v3
 Xcode/*.xcodeproj/*.pbxuser
-build
+build*
 *~
 .*.swp
 lugaru*
index 1846e12402082c789de2ee19512f873d07b2cc0b..27671e7ca75bc95a6b5914a9eda92a6ef1a7528e 100644 (file)
@@ -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
index 522b22f71f2bbe92ccf62c785b452d63baca94cf..29f70ebc0d75c3ce11e49e4de5b16194790445d3 100644 (file)
@@ -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=<stdint.h>)
     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=<stdint.h>)
 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)
index 745cc17ff83699fd8fc8a4fdf46139036a803ebb..5b9ab9e48f095846bd2135294399170df32154f2 100644 (file)
@@ -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
 ```