summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt66
1 files changed, 60 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36731ef..8592b8c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,6 +9,9 @@ endif()
set(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g")
set(CMAKE_MACOSX_RPATH OFF)
+set(mcc_VERSION_MAJOR 0)
+set(mcc_VERSION_MINOR 1)
+
find_package(PkgConfig REQUIRED)
pkg_search_module(PKG_libevent REQUIRED IMPORTED_TARGET libevent)
pkg_search_module(PKG_json_c REQUIRED IMPORTED_TARGET json-c)
@@ -17,14 +20,39 @@ find_package(ZLIB)
add_subdirectory(subprojects/cNBT)
include_directories(subprojects)
+include_directories("${PROJECT_BINARY_DIR}")
-if(NOT ${CMAKE_GENERATOR} STREQUAL "Xcode")
- message(STATUS "generator: Not Xcode")
- message(STATUS "set entitlements for mcc")
- set_target_properties(mcc PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_LIST_DIR}/mcc.entitlements")
+find_program(
+ nbted
+ nbted
+)
+add_custom_command(
+ OUTPUT "${PROJECT_BINARY_DIR}/config.dat"
+ COMMAND ${nbted} -r -i ${PROJECT_SOURCE_DIR}/data/config.nbted > ${PROJECT_BINARY_DIR}/config.dat
+ DEPENDS "${PROJECT_SOURCE_DIR}/data/config.nbted"
+)
+add_custom_command(
+ OUTPUT "${PROJECT_BINARY_DIR}/dimension_registry.dat"
+ COMMAND ${nbted} -r -i ${PROJECT_SOURCE_DIR}/data/dimension_registry.nbted > ${PROJECT_BINARY_DIR}/dimension_registry.dat
+ DEPENDS "${PROJECT_SOURCE_DIR}/data/dimension_registry.nbted"
+)
+
+if (NOT DEFINED mcc_RESOURCE_PATH)
+if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ message(STATUS "building on macOS with ../Resource path")
+ set(mcc_RESOURCE_PATH ../Resources)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ message(STATUS "building on linux with ./Resource path")
+ set(mcc_RESOURCE_PATH ./Resources)
endif()
+endif()
+
+configure_file(
+ "${PROJECT_SOURCE_DIR}/config.h.in"
+ "${PROJECT_BINARY_DIR}/config.h"
+)
-ADD_EXECUTABLE(mcc
+add_executable(mcc
main.c
main.h
socket.c
@@ -37,6 +65,33 @@ ADD_EXECUTABLE(mcc
package.h
world.c
world.h
+ ${PROJECT_SOURCE_DIR}/config.h.in
+
+
+ # config source
+ ${PROJECT_SOURCE_DIR}/data/config.nbted
+ ${PROJECT_SOURCE_DIR}/data/dimension_registry.nbted
+
+ # config
+ ${PROJECT_BINARY_DIR}/config.dat
+ ${PROJECT_BINARY_DIR}/dimension_registry.dat
+)
+
+set(RESOURCE_FILES
+ ${PROJECT_BINARY_DIR}/config.dat
+ ${PROJECT_BINARY_DIR}/dimension_registry.dat
+)
+
+if(NOT ${CMAKE_GENERATOR} STREQUAL "Xcode")
+ message(STATUS "generator: Not Xcode")
+ message(STATUS "set entitlements for mcc")
+ set_target_properties(mcc PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_LIST_DIR}/mcc.entitlements")
+endif()
+
+set_target_properties(mcc PROPERTIES
+ MACOSX_BUNDLE TRUE
+ MACOSX_FRAMEWORK_IDENTIFIER dev.kloenk.mcc
+ RESOURCE "${RESOURCE_FILES}"
)
#TARGET_LINK_LIBRARIES(mcc PkgConfig::PKG_json_c PkgConfig::PKG_libevent )
@@ -45,5 +100,4 @@ TARGET_LINK_LIBRARIES(mcc PkgConfig::PKG_libevent)
TARGET_LINK_LIBRARIES(mcc nbt)
TARGET_LINK_LIBRARIES(mcc ZLIB::ZLIB)
-
install(TARGETS mcc DESTINATION "${CMAKE_INSTALL_PREFIX}")