2017-11-30 21:00:47 +01:00
|
|
|
cmake_minimum_required (VERSION 3.2.0)
|
|
|
|
|
|
|
|
SET(CMAKE_COLOR_MAKEFILE ON)
|
|
|
|
|
|
|
|
project(breakhack C)
|
|
|
|
|
2017-12-05 12:40:37 +01:00
|
|
|
include(FindLua)
|
2018-02-22 13:02:40 +01:00
|
|
|
include(FindPhysFS)
|
2017-12-13 12:09:04 +01:00
|
|
|
include(cmake/FindSDL2.cmake)
|
|
|
|
include(cmake/FindSDL2_image.cmake)
|
|
|
|
include(cmake/FindSDL2_ttf.cmake)
|
2018-02-14 16:04:40 +01:00
|
|
|
include(cmake/FindSDL2_mixer.cmake)
|
2018-02-16 10:13:16 +01:00
|
|
|
include(cmake/FindCCache.cmake)
|
2017-12-19 19:42:05 +01:00
|
|
|
|
|
|
|
if (NOT WIN32)
|
2017-12-19 21:00:02 +01:00
|
|
|
include(FindX11)
|
2017-12-19 19:42:05 +01:00
|
|
|
include(cmake/FindCheck.cmake)
|
|
|
|
endif (NOT WIN32)
|
2017-12-05 12:40:37 +01:00
|
|
|
|
2017-12-21 11:57:12 +01:00
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/src/config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/config.h"
|
|
|
|
)
|
|
|
|
|
2018-02-22 13:02:40 +01:00
|
|
|
if (NOT PHYSFS_FOUND)
|
|
|
|
add_subdirectory(physfs-3.0.1)
|
|
|
|
include_directories(
|
2018-02-22 13:08:57 +01:00
|
|
|
physfs-3.0.1/src
|
2018-02-22 13:02:40 +01:00
|
|
|
)
|
|
|
|
else (NOT PHYSFS_FOUND)
|
|
|
|
include_directories(
|
|
|
|
${PHYSFS_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
endif (NOT PHYSFS_FOUND)
|
|
|
|
|
2017-12-13 12:09:04 +01:00
|
|
|
include_directories(
|
2017-12-19 21:00:02 +01:00
|
|
|
${PROJECT_BINARY_DIR}
|
2017-12-05 12:51:09 +01:00
|
|
|
${LUA_INCLUDE_DIR}
|
2017-12-13 12:09:04 +01:00
|
|
|
${SDL2_INCLUDE_DIR}
|
|
|
|
${SDL2_IMAGE_INCLUDE_DIR}
|
|
|
|
${SDL2_TTF_INCLUDE_DIR}
|
2018-02-14 16:04:40 +01:00
|
|
|
${SDL2_MIXER_INCLUDE_DIR}
|
2017-12-05 12:40:37 +01:00
|
|
|
)
|
|
|
|
|
2017-12-19 21:00:02 +01:00
|
|
|
if (NOT WIN32)
|
|
|
|
include_directories(
|
|
|
|
${X11_INCLUDE_DIR}
|
|
|
|
${CHECK_INCLUDE_DIR}
|
|
|
|
)
|
|
|
|
endif (NOT WIN32)
|
|
|
|
|
2017-12-19 22:51:00 +01:00
|
|
|
if (NOT WIN32)
|
2018-02-02 16:16:55 +01:00
|
|
|
add_definitions(-std=gnu11
|
|
|
|
-pedantic -Wall -Wextra -Wshadow
|
|
|
|
-Wpointer-arith -Wcast-qual
|
|
|
|
-Wstrict-prototypes
|
|
|
|
-Wmissing-prototypes
|
2018-02-22 09:44:27 +01:00
|
|
|
-Wconversion -Wno-sign-conversion
|
2018-02-02 16:16:55 +01:00
|
|
|
)
|
2017-12-19 22:51:00 +01:00
|
|
|
endif (NOT WIN32)
|
2017-11-30 21:00:47 +01:00
|
|
|
|
2018-02-03 23:39:49 +01:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
|
2018-02-03 13:02:39 +01:00
|
|
|
|
2017-11-30 21:00:47 +01:00
|
|
|
# PROGRAMS:
|
2017-12-01 16:03:19 +01:00
|
|
|
add_executable(breakhack
|
2017-11-30 21:00:47 +01:00
|
|
|
src/main
|
|
|
|
src/texture
|
|
|
|
src/screenresolution
|
|
|
|
src/sprite
|
|
|
|
src/util
|
|
|
|
src/player
|
2017-12-01 16:03:19 +01:00
|
|
|
src/map
|
2017-12-02 23:32:40 +01:00
|
|
|
src/map_lua
|
2017-12-01 16:03:19 +01:00
|
|
|
src/camera
|
2017-12-05 08:30:08 +01:00
|
|
|
src/timer
|
2017-12-05 15:03:20 +01:00
|
|
|
src/roommatrix
|
|
|
|
src/position
|
2017-12-13 14:26:30 +01:00
|
|
|
src/monster
|
2017-12-15 08:08:45 +01:00
|
|
|
src/stats
|
2017-12-15 15:03:29 +01:00
|
|
|
src/actiontext
|
2017-12-17 13:43:41 +01:00
|
|
|
src/random
|
2017-12-19 09:06:21 +01:00
|
|
|
src/linkedlist
|
|
|
|
src/hashtable
|
2017-12-22 15:15:40 +01:00
|
|
|
src/gui
|
2018-01-24 21:14:34 +01:00
|
|
|
src/item
|
|
|
|
src/item_builder
|
2018-01-31 09:15:33 +01:00
|
|
|
src/pointer
|
2018-02-02 16:16:55 +01:00
|
|
|
src/gui_button
|
2018-02-03 23:39:49 +01:00
|
|
|
src/particle_engine
|
2018-02-08 17:01:38 +01:00
|
|
|
src/menu
|
2018-02-09 06:53:06 +01:00
|
|
|
src/collisions
|
2018-02-12 10:55:36 +01:00
|
|
|
src/keyboard
|
2018-02-14 16:04:40 +01:00
|
|
|
src/mixer
|
2018-02-22 12:36:24 +01:00
|
|
|
src/io_util
|
|
|
|
src/physfsrwops
|
2018-02-23 11:01:25 +01:00
|
|
|
src/skillbar
|
2017-11-30 21:00:47 +01:00
|
|
|
)
|
|
|
|
|
2017-12-01 16:03:19 +01:00
|
|
|
target_link_libraries(breakhack
|
2017-12-13 12:09:04 +01:00
|
|
|
${LUA_LIBRARY}
|
|
|
|
${SDL2_LIBRARY}
|
2018-02-22 13:12:59 +01:00
|
|
|
${SDL2MAIN_LIBRARY}
|
2017-12-13 12:09:04 +01:00
|
|
|
${SDL2_IMAGE_LIBRARY}
|
|
|
|
${SDL2_TTF_LIBRARY}
|
2018-02-14 16:04:40 +01:00
|
|
|
${SDL2_MIXER_LIBRARY}
|
2017-11-30 21:00:47 +01:00
|
|
|
)
|
|
|
|
|
2018-02-22 13:02:40 +01:00
|
|
|
if (NOT PHYSFS_FOUND)
|
|
|
|
target_link_libraries(breakhack
|
|
|
|
physfs
|
|
|
|
)
|
|
|
|
else (NOT PHYSFS_FOUND)
|
|
|
|
target_link_libraries(breakhack
|
|
|
|
${PHYSFS_LIBRARY}
|
|
|
|
)
|
|
|
|
endif (NOT PHYSFS_FOUND)
|
|
|
|
|
2017-12-19 21:00:02 +01:00
|
|
|
if (NOT WIN32)
|
|
|
|
target_link_libraries(breakhack
|
|
|
|
${X11_LIBRARIES}
|
|
|
|
)
|
|
|
|
endif (NOT WIN32)
|
|
|
|
|
2017-11-30 21:00:47 +01:00
|
|
|
# TESTS:
|
2017-12-21 11:57:12 +01:00
|
|
|
IF (CHECK_FOUND AND NOT WIN32)
|
2017-12-13 12:18:20 +01:00
|
|
|
find_package(Threads REQUIRED)
|
2017-12-13 12:09:04 +01:00
|
|
|
enable_testing()
|
|
|
|
add_executable(test_util test/check_util src/util)
|
2017-12-13 12:18:20 +01:00
|
|
|
target_link_libraries(test_util ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
2017-12-13 12:09:04 +01:00
|
|
|
add_test(test_util test_util)
|
2017-12-19 09:06:21 +01:00
|
|
|
|
2018-01-23 23:09:12 +01:00
|
|
|
add_executable(test_linkedlist test/check_linkedlist src/linkedlist src/util)
|
2017-12-19 09:06:21 +01:00
|
|
|
target_link_libraries(test_linkedlist ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
add_test(test_linkedlist test_linkedlist)
|
|
|
|
|
2018-01-23 23:09:12 +01:00
|
|
|
add_executable(test_hashtable test/check_hashtable src/hashtable src/util)
|
2017-12-19 09:06:21 +01:00
|
|
|
target_link_libraries(test_hashtable ${CHECK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
add_test(test_hashtable test_hashtable)
|
2017-12-21 11:57:12 +01:00
|
|
|
ENDIF (CHECK_FOUND AND NOT WIN32)
|
2018-02-22 19:17:57 +01:00
|
|
|
|
|
|
|
if (NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
add_custom_target(assets_pack ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E tar "-cf" "../assets.pack" "--format=zip" --
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/assets/Characters"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/assets/Commissions"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/assets/GUI"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/assets/Items"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/assets/Objects"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/assets/Sounds"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets
|
|
|
|
)
|
|
|
|
endif (NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
2018-02-22 23:19:33 +01:00
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
set(DLL_FILES
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libFLAC-8.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libfreetype-6.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libmodplug-1.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libmpg123-0.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libogg-0.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libpng16-16.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libvorbis-0.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/libvorbisfile-3.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/physfs.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/SDL2.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/SDL2_image.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/SDL2_mixer.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/SDL2_ttf.dll
|
|
|
|
${CMAKE_SOURCE_DIR}/bin/zlib1.dll
|
|
|
|
)
|
|
|
|
endif (WIN32)
|
|
|
|
|
2018-02-23 07:17:55 +01:00
|
|
|
include(InstallRequiredSystemLibraries)
|
|
|
|
set(CPACK_PACKAGE_NAME "BreakHack")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "OliveShark")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
|
|
|
|
set(CPACK_PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package)
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "1")
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH "1")
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "BreakHack")
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "breakhack-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
|
|
|
set(CPACK_PACKAGE_CHECKSUM "MD5")
|
|
|
|
set(CPACK_INSTALL_CMAKE_PROJECTS ${PROJECT_BINARY_DIR} breakhack Release package)
|
|
|
|
if(UNIX)
|
|
|
|
set(CPACK_STRIP_FILES breakhack)
|
|
|
|
set(CPACK_SOURCE_STRIP_FILES "")
|
|
|
|
endif(UNIX)
|
|
|
|
set(CPACK_PACKAGE_EXECUTABLES breakhack "BreakHack")
|
|
|
|
include(CPack)
|
|
|
|
|
|
|
|
INSTALL(TARGETS breakhack
|
2018-02-22 23:19:33 +01:00
|
|
|
COMPONENT Release
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
)
|
2018-02-23 07:17:55 +01:00
|
|
|
INSTALL(FILES assets.pack
|
2018-02-22 23:19:33 +01:00
|
|
|
COMPONENT Release
|
|
|
|
DESTINATION bin
|
|
|
|
)
|
2018-02-23 07:17:55 +01:00
|
|
|
INSTALL(DIRECTORY data
|
2018-02-22 23:19:33 +01:00
|
|
|
COMPONENT Release
|
|
|
|
DESTINATION bin
|
|
|
|
)
|
|
|
|
if (WIN32)
|
2018-02-23 07:17:55 +01:00
|
|
|
INSTALL(FILES ${DLL_FILES} DESTINATION bin)
|
2018-02-22 23:19:33 +01:00
|
|
|
endif (WIN32)
|