Skip to content

Commit 7d98768

Browse files
committed
Make CMake implementation more sane and add installation
1 parent f154ce2 commit 7d98768

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

CMakeLists.txt

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
22
set(CMAKE_LEGACY_CYGWIN32 0)
33

4-
project("AshleyCPP")
4+
project(AshleyCPP)
5+
6+
set(VERSION_MAJOR 1)
7+
set(VERSION_MINOR 0)
8+
set(VERSION_PATCH 0)
9+
10+
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
11+
message("Conifguring AshleyCPP version ${VERSION}.")
512

613
set(dialect "-std=c++0x")
7-
set(warnings "-Wall")
8-
set(flags "-fmessage-length=0")
14+
set(warnings "-Wall -Wextra -Wno-unused-parameter")
15+
set(flags "-fPIC")
916
set(ASHLEY_DEBUG_FLAGS "-O0 -g3")
1017
set(ASHLEY_RELEASE_FLAGS "-O3 -g0")
1118

1219
set(CMAKE_CXX_COMPILER_ARG1 "-std=c++0x")
1320
set(CMAKE_CXX_FLAGS_BASE "${warnings} ${flags} ${debug_flags}")
1421

15-
include_directories("include" "test")
22+
include_directories(include test)
1623

17-
set(ASHLEY_CPP_SOURCES
18-
src/ComponentType.cpp
19-
src/Engine.cpp
20-
src/Entity.cpp
21-
src/Family.cpp
22-
src/IntervalIteratingSystem.cpp
23-
src/IntervalSystem.cpp
24-
src/IteratingSystem.cpp)
24+
file(GLOB_RECURSE ASHLEY_CPP_SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
25+
file(GLOB ASHLEY_CPP_HEADERS ${PROJECT_SOURCE_DIR}/include/*.hpp)
2526

2627
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BASE} ${ASHLEY_DEBUG_FLAGS}")
2728
add_library(AshleyCPP-d ${ASHLEY_CPP_SOURCES})
@@ -30,26 +31,21 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BASE} ${ASHLEY_RELEASE_FLAGS}")
3031
add_library(AshleyCPP ${ASHLEY_CPP_SOURCES})
3132

3233
if (NOT EXCLUDE_TESTS)
33-
find_package(GTest REQUIRED)
34-
35-
set (ASHLEY_TEST_SOURCES
36-
test/core/ComponentMapperTests.cpp
37-
test/core/ComponentTypeTest.cpp
38-
test/core/EngineTests.cpp
39-
test/core/EntityTests.cpp
40-
test/core/FamilyTests.cpp
41-
42-
test/signals/SignalTests.cpp
43-
44-
test/systems/IntervalIteratingSystemTests.cpp
45-
test/systems/IntervalSystemTests.cpp
46-
test/systems/IteratingSystemTests.cpp)
47-
48-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BASE} -pthread ${ASHLEY_DEBUG_FLAGS}")
49-
50-
include_directories(${GTEST_INCLUDE_DIRS})
51-
52-
add_executable(AshleyCPPTest ${ASHLEY_TEST_SOURCES})
53-
target_link_libraries(AshleyCPPTest AshleyCPP-d ${GTEST_BOTH_LIBRARIES})
34+
find_package(GTest REQUIRED)
35+
36+
file (GLOB_RECURSE ASHLEY_TEST_SOURCES ${PROJECT_SOURCE_DIR}/test/*.cpp)
37+
38+
set(ASHLEY_TEST_FLAGS "-pthread")
39+
40+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BASE} ${ASHLEY_DEBUG_FLAGS} ${ASHLEY_TEST_FLAGS}")
41+
42+
include_directories(${GTEST_INCLUDE_DIRS})
43+
44+
add_executable(AshleyCPPTest ${ASHLEY_TEST_SOURCES})
45+
target_link_libraries(AshleyCPPTest AshleyCPP-d ${GTEST_BOTH_LIBRARIES})
5446
endif (NOT EXCLUDE_TESTS)
5547

48+
install (TARGETS AshleyCPP-d DESTINATION lib)
49+
install (TARGETS AshleyCPP DESTINATION lib)
50+
install (DIRECTORY ${PROJECT_SOURCE_DIR}/include/Ashley DESTINATION include)
51+

0 commit comments

Comments
 (0)