Skip to content

Commit

Permalink
CMake: Drop LUGARU_INSTALL_PREFIX and clean CMakeLists
Browse files Browse the repository at this point in the history
In the cleanup:
- Added section separators for clarity
- Enforced lower case commands with no space before parenthesis
  • Loading branch information
akien-mga committed Nov 20, 2016
1 parent e9b7737 commit 1cd298a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .doozer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ run
Xcode/build
Xcode/*.xcodeproj/*.mode1v3
Xcode/*.xcodeproj/*.pbxuser
build
build*
*~
.*.swp
lugaru*
Expand Down
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
59 changes: 31 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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")
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions COMPILING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
```

0 comments on commit 1cd298a

Please sign in to comment.