Skip to content

Commit d154016

Browse files
committed
Add project files for CMake
1 parent 878f590 commit d154016

File tree

5 files changed

+115
-26
lines changed

5 files changed

+115
-26
lines changed

CMakeLists.txt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
project(SimpleNormalMapper)
2+
3+
cmake_minimum_required(VERSION 2.8.12)
4+
cmake_policy(VERSION 2.8.12)
5+
6+
if(POLICY CMP0005)
7+
cmake_policy(SET CMP0005 NEW)
8+
endif()
9+
10+
if(POLICY CMP0020)
11+
cmake_policy(SET CMP0020 NEW)
12+
endif()
13+
14+
if(POLICY CMP0043)
15+
cmake_policy(SET CMP0043 NEW)
16+
endif()
17+
18+
if(POLICY CMP0071)
19+
cmake_policy(SET CMP0071 NEW)
20+
endif()
21+
22+
# Global game version
23+
set(VERSION_MAJOR "1")
24+
set(VERSION_MINOR "1")
25+
set(VERSION_PATCH "0")
26+
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
27+
28+
# Default to release C++ flags if CMAKE_BUILD_TYPE not set
29+
if(NOT CMAKE_BUILD_TYPE)
30+
set(CMAKE_BUILD_TYPE Release CACHE STRING
31+
"Choose the type of build, options are: None Debug Release RelWithDebInfo
32+
MinSizeRel." FORCE)
33+
endif()
34+
35+
set(CMAKE_CXX_STANDARD 11)
36+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
37+
38+
if(CMAKE_COMPILER_IS_GNUCXX OR MINGW OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
39+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic")
40+
41+
# CMAKE_CXX_STANDARD supported only by versions >= 3.1
42+
if (CMAKE_VERSION VERSION_LESS "3.1")
43+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
44+
endif ()
45+
46+
# Automatically use ccache if found
47+
find_program(CCACHE_FOUND ccache)
48+
if(CCACHE_FOUND)
49+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
50+
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
51+
endif(CCACHE_FOUND)
52+
53+
elseif(MSVC)
54+
add_definitions(-DNOMINMAX)
55+
endif()
56+
57+
set(BINARY_NAME "snm")
58+
59+
add_definitions(-DVERSION="${VERSION}")
60+
61+
set(CMAKE_AUTOMOC ON)
62+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
63+
set(QT_MIN_VER 5.5.1) # The version in Ubuntu 16.04
64+
find_package(Qt5Core ${QT_MIN_VER} REQUIRED)
65+
find_package(Qt5Widgets ${QT_MIN_VER} REQUIRED)
66+
67+
add_subdirectory(src)
68+

INSTALL

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ a 3D object.
1919
## Building the project
2020

2121
Simple Normal Mapper is developed in C++/Qt so it can be built on any
22-
platform that Qt5 runs on.
22+
platform that Qt5 runs on. There are project files for `qmake` and `CMake`.
2323

24-
Please refer to the INSTALL document for build/install instructions if you're
25-
going to build Simple Normal Mapper from sources.
24+
Building in CLI with CMake:
25+
26+
```
27+
$ mkdir build && cd build
28+
$ cmake ..
29+
$ make
30+
```
2631

2732
## Licence
2833

configure

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Set sources
2+
set(SRC
3+
AboutDlg.cpp
4+
Config.cpp
5+
ControlToolBar.cpp
6+
Editor.cpp
7+
EditorScene.cpp
8+
EditorView.cpp
9+
main.cpp
10+
MainWindow.cpp
11+
Renderer.cpp
12+
RenderPreview.cpp
13+
Settings.cpp
14+
)
15+
16+
set(RCS
17+
${CMAKE_SOURCE_DIR}/data/icons/Icons.qrc
18+
)
19+
20+
qt5_add_resources(RC_SRC ${RCS})
21+
22+
# Resource compilation for MinGW
23+
if(MINGW)
24+
add_custom_command(
25+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/windowsrc.o
26+
COMMAND
27+
${CMAKE_RC_COMPILER}
28+
-I${CMAKE_SOURCE_DIR} -i${CMAKE_SOURCE_DIR}/data/icons/Windows.rc
29+
-o ${CMAKE_CURRENT_BINARY_DIR}/windowsrc.o)
30+
set(SRC ${SRC} ${CMAKE_CURRENT_BINARY_DIR}/windowsrc.o)
31+
endif()
32+
33+
# Add the executable
34+
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
35+
add_executable(${BINARY_NAME} WIN32 ${SRC} ${MOC_SRC} ${RC_SRC})
36+
install(PROGRAMS ${CMAKE_BINARY_DIR}/${BINARY_NAME} DESTINATION bin)
37+
38+
target_link_libraries(${BINARY_NAME} Qt5::Widgets)
39+

0 commit comments

Comments
 (0)