-
Notifications
You must be signed in to change notification settings - Fork 7
Add CMake build system and and updated README.md #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| cmake_minimum_required( VERSION 3.5 ) | ||
|
|
||
| project( ADiKtED LANGUAGES C ) | ||
| set(PROJECT_DESCRIPTION "Dungeon Keeper 1 map editor") | ||
|
|
||
| include(GNUInstallDirs) | ||
| include(FindPkgConfig) | ||
|
|
||
| if( NOT CMAKE_BUILD_TYPE ) | ||
| set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE ) | ||
| endif() | ||
|
|
||
| set( CMAKE_C_STANDARD 99 ) | ||
| set( CMAKE_C_STANDARD_REQUIRED ON ) | ||
|
|
||
| set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-switch" ) | ||
| set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic" ) | ||
| set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra" ) | ||
| set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Wno-conversion -Wno-traditional-conversion -Wno-sign-compare" ) | ||
|
|
||
| list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
|
|
||
| include(LibFindMacros) | ||
| include(FindMath) | ||
| include(FindBsd) | ||
|
|
||
| # Add examples | ||
| include(cmake/examples.cmake) | ||
| option( ADIKTED_BUILD_EXAMPLES "Build ADiKtEd examples" ON ) | ||
| if( ADIKTED_BUILD_EXAMPLES ) | ||
| set( | ||
| ADIKTED_EXAMPLES | ||
| putgems | ||
| puttrain | ||
| viewmap | ||
| putemple | ||
| ) | ||
|
|
||
| foreach( EXAMPLE ${ADIKTED_EXAMPLES} ) | ||
| add_example( ${EXAMPLE} ) | ||
| endforeach() | ||
| endif() | ||
|
|
||
| add_subdirectory(libadikted) | ||
| add_subdirectory(mapslang) | ||
|
|
||
| install( TARGETS ${ADIKTED_EXAMPLES} RUNTIME | ||
| DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binaries) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Adikted Dungeon Keeper Map Editor | ||
|
|
||
| Note - there is now a manual available for ADiKtEd. | ||
| It even includes a basic tutorial to quickly learn the program. | ||
| A version of it is included within this distribution, | ||
| called `dk_adikted_manual.htm`. You may wish to print this out. | ||
| ## Build | ||
|
|
||
| ### Unix-like systems | ||
|
|
||
| #### CMake | ||
|
|
||
| Run | ||
| `cmake --install-prefix=/usr . && make install` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change to I also don't think we should be suggesting
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was not able to reproduce the error using Linux x86_64. |
||
| and copy the examples to the keeperfx directory | ||
|
|
||
| ### Windows | ||
|
|
||
| #### make | ||
|
|
||
| Run `cd libadikted/ && make -f Makefile.win && cd mapslang && make -f Makefile.win` | ||
|
|
||
| Here's the Win32 version executable. Just put all the | ||
| files in the same directory, edit map.ini as appropriate (you should | ||
| change paths to your DK files; you can also change other parameters | ||
| if you want), and run it. | ||
|
|
||
| ## Usage | ||
|
|
||
| Run `map [mapfile] [-m <logfile>] [-v] [-r] [-n] [-s [mapfile]] [-q]` | ||
|
|
||
| When ADiKtEd saves a map, it will ask you what you wish to call it | ||
| (unless you're not using quick save). I suggest you don't save | ||
| directly over the Dungeon Keeper original levels, but keep it | ||
| in the current directory until you're finished. | ||
| Then, at end, save it on `map00001` to access it easily in the game. | ||
|
|
||
| You'll need a level script for your newly created level. You may be | ||
| able to get by with the script which comes with the original level 1 | ||
| - ie just copy it and paste into TXT file of your new map - but | ||
| if not, study the level scripts reference from `dk_scripting_ref.htm`. | ||
| You can also try looking at the original DK and DD levels for examples. | ||
|
|
||
| Press F1 for help. | ||
|
|
||
| ## TODO before final | ||
| Fixations in room things parameters (height,other) | ||
| Fixations in room corner graphics | ||
|
|
||
| ## Author | ||
| Jon Skeet, skeet@pobox.com | ||
|
|
||
| Dev-C++ IDE version, | ||
| rewritten most of the code: | ||
| Tomasz Lis | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Find Bsd compat lib | ||
| # | ||
| # Once done, this will define: | ||
| # | ||
| # Bsd_FOUND - system has Bsd compat | ||
| # Bsd_INCLUDE_DIRS - the Bsd compat include directories | ||
| # Bsd_LIBRARIES - link these to use Bsd compat | ||
| # | ||
|
|
||
| include(LibFindMacros) | ||
|
|
||
| if (BSD_INCLUDE_DIR AND BSD_LIBRARY) | ||
| # Already in cache, be silent | ||
| set(BSD_FIND_QUIETLY TRUE) | ||
| endif () | ||
|
|
||
| libfind_pkg_check_modules(BSD_PKGCONF libbsd) | ||
|
|
||
| find_path(BSD_INCLUDE_DIR bsd.h | ||
| PATH_SUFFIX bsd | ||
| PATHS ${BSD_PKGCONF_INCLUDE_DIRS} | ||
| ) | ||
|
|
||
| find_library(BSD_LIBRARY | ||
| NAMES bsd | ||
| PATHS ${BSD_PKGCONF_LIBRARY_DIRS} | ||
| ) | ||
|
|
||
| set(BSD_PROCESS_INCLUDES ${BSD_INCLUDE_DIR}) | ||
| set(BSD_PROCESS_LIBS ${BSD_LIBRARY}) | ||
| libfind_process(BSD) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| include (CheckLibraryExists) | ||
| set(Math_FOUND FALSE) | ||
| set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) | ||
| set(CMAKE_REQUIRED_QUIET ${Math_FIND_QUIETLY}) | ||
|
|
||
| if(CMAKE_C_COMPILER_LOADED) | ||
| include (CheckIncludeFile) | ||
| include (CheckCSourceCompiles) | ||
| elseif(CMAKE_CXX_COMPILER_LOADED) | ||
| include (CheckIncludeFileCXX) | ||
| include (CheckCXXSourceCompiles) | ||
| else() | ||
| message(FATAL_ERROR "FindMath only works if either C or CXX language is enabled") | ||
| endif() | ||
|
|
||
| set(MATH_C_CXX_TEST_SOURCE [====[ | ||
| #include <math.h> | ||
|
|
||
| int main() | ||
| { | ||
| const double x = 7.3; | ||
| ceil(x); | ||
| acos(x); | ||
| sin(x); | ||
| sqrt(x); | ||
|
|
||
| return 0; | ||
| } | ||
| ]====]) | ||
|
|
||
|
|
||
| if(CMAKE_C_COMPILER_LOADED) | ||
| CHECK_INCLUDE_FILE("math.h" CMAKE_HAVE_MATH_H) | ||
| else() | ||
| CHECK_INCLUDE_FILE_CXX("math.h" CMAKE_HAVE_MATH_H) | ||
| endif() | ||
|
|
||
| if(CMAKE_HAVE_MATH_H) | ||
| set(CMAKE_HAVE_MATH_LIBRARY) | ||
|
|
||
| set(CMAKE_REQUIRED_LIBRARIES -lm) | ||
| if(CMAKE_C_COMPILER_LOADED) | ||
| CHECK_C_SOURCE_COMPILES("${MATH_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_LIBM) | ||
| elseif(CMAKE_CXX_COMPILER_LOADED) | ||
| CHECK_CXX_SOURCE_COMPILES("${MATH_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_LIBM) | ||
| endif() | ||
|
|
||
| if(CMAKE_HAVE_LIBC_LIBM) | ||
| set(CMAKE_MATH_LIBS_INIT ${CMAKE_REQUIRED_LIBRARIES}) | ||
| set(CMAKE_HAVE_MATH_LIBRARY 1) | ||
| set(Math_FOUND TRUE) | ||
| else() | ||
| set(Math_FOUND FALSE) | ||
| endif() | ||
|
|
||
| unset(CMAKE_REQUIRED_LIBRARIES) | ||
| set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
| FIND_PACKAGE_HANDLE_STANDARD_ARGS(Math DEFAULT_MSG Math_FOUND) | ||
|
|
||
| if(MATH_FOUND AND NOT TARGET Math::Math) | ||
| add_library(Math::Math INTERFACE IMPORTED) | ||
|
|
||
| if(CMAKE_MATH_LIBS_INIT) | ||
| set_property(TARGET Math::Math PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_MATH_LIBS_INIT}") | ||
| endif() | ||
| elseif(NOT MATH_FOUND) | ||
| file(APPEND | ||
| ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log | ||
| "Determining if compiler accepts -lm failed with the following output:\n${_cmake_find_math_output}\n\n") | ||
| message(SEND_ERROR "Required Math library not found!") | ||
| endif() | ||
| endif() | ||
|
|
||
| unset(_cmake_find_math_output) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments | ||
| # used for the current package. For this to work, the first parameter must be the | ||
| # prefix of the current package, then the prefix of the new package etc, which are | ||
| # passed to find_package. | ||
| macro (libfind_package PREFIX) | ||
| set (LIBFIND_PACKAGE_ARGS ${ARGN}) | ||
| if (${PREFIX}_FIND_QUIETLY) | ||
| set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET) | ||
| endif (${PREFIX}_FIND_QUIETLY) | ||
| if (${PREFIX}_FIND_REQUIRED) | ||
| set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED) | ||
| endif (${PREFIX}_FIND_REQUIRED) | ||
| find_package(${LIBFIND_PACKAGE_ARGS}) | ||
| endmacro (libfind_package) | ||
|
|
||
| # CMake developers made the UsePkgConfig system deprecated in the same release (2.6) | ||
| # where they added pkg_check_modules. Consequently I need to support both in my scripts | ||
| # to avoid those deprecated warnings. Here's a helper that does just that. | ||
| # Works identically to pkg_check_modules, except that no checks are needed prior to use. | ||
| macro (libfind_pkg_check_modules PREFIX PKGNAME) | ||
| if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) | ||
| include(UsePkgConfig) | ||
| pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) | ||
| else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) | ||
| find_package(PkgConfig) | ||
| if (PKG_CONFIG_FOUND) | ||
| pkg_check_modules(${PREFIX} ${PKGNAME}) | ||
| endif (PKG_CONFIG_FOUND) | ||
| endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) | ||
| endmacro (libfind_pkg_check_modules) | ||
|
|
||
| # Do the final processing once the paths have been detected. | ||
| # If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain | ||
| # all the variables, each of which contain one include directory. | ||
| # Ditto for ${PREFIX}_PROCESS_LIBS and library files. | ||
| # Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. | ||
| # Also handles errors in case library detection was required, etc. | ||
| macro (libfind_process PREFIX) | ||
| # Skip processing if already processed during this run | ||
| if (NOT ${PREFIX}_FOUND) | ||
| # Start with the assumption that the library was found | ||
| set (${PREFIX}_FOUND TRUE) | ||
|
|
||
| # Process all includes and set _FOUND to false if any are missing | ||
| foreach (i ${${PREFIX}_PROCESS_INCLUDES}) | ||
| if (${i}) | ||
| set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) | ||
| mark_as_advanced(${i}) | ||
| else (${i}) | ||
| set (${PREFIX}_FOUND FALSE) | ||
| endif (${i}) | ||
| endforeach (i) | ||
|
|
||
| # Process all libraries and set _FOUND to false if any are missing | ||
| foreach (i ${${PREFIX}_PROCESS_LIBS}) | ||
| if (${i}) | ||
| set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) | ||
| mark_as_advanced(${i}) | ||
| else (${i}) | ||
| set (${PREFIX}_FOUND FALSE) | ||
| endif (${i}) | ||
| endforeach (i) | ||
|
|
||
| # Print message and/or exit on fatal error | ||
| if (${PREFIX}_FOUND) | ||
| if (NOT ${PREFIX}_FIND_QUIETLY) | ||
| message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") | ||
| endif (NOT ${PREFIX}_FIND_QUIETLY) | ||
| else (${PREFIX}_FOUND) | ||
| if (${PREFIX}_FIND_REQUIRED) | ||
| foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) | ||
| message("${i}=${${i}}") | ||
| endforeach (i) | ||
| message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.") | ||
| endif (${PREFIX}_FIND_REQUIRED) | ||
| endif (${PREFIX}_FOUND) | ||
| endif (NOT ${PREFIX}_FOUND) | ||
| endmacro (libfind_process) | ||
|
|
||
| macro(libfind_library PREFIX basename) | ||
| set(TMP "") | ||
| if(MSVC80) | ||
| set(TMP -vc80) | ||
| endif(MSVC80) | ||
| if(MSVC90) | ||
| set(TMP -vc90) | ||
| endif(MSVC90) | ||
| set(${PREFIX}_LIBNAMES ${basename}${TMP}) | ||
| if(${ARGC} GREATER 2) | ||
| set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) | ||
| string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) | ||
| set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) | ||
| endif(${ARGC} GREATER 2) | ||
| find_library(${PREFIX}_LIBRARY | ||
| NAMES ${${PREFIX}_LIBNAMES} | ||
| PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS} | ||
| ) | ||
| endmacro(libfind_library) | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| function( add_example ARG_NAME ) | ||
| list( APPEND ARG_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/examples/${ARG_NAME}" ) | ||
| set( SOURCES "" ) | ||
| set( RESOURCES "" ) | ||
| foreach( DIR ${ARG_DIRECTORIES} ) | ||
| file( GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.h ) | ||
| list( APPEND SOURCES ${GLOB_SOURCES} ) | ||
| file( GLOB GLOB_RESOURCES ${DIR}/*.rc ) | ||
| list( APPEND RESOURCES ${GLOB_RESOURCES} ) | ||
| endforeach() | ||
| add_executable( ${ARG_NAME} ${SOURCES} ) | ||
| target_link_libraries( ${ARG_NAME} PUBLIC adikted ) | ||
| find_package( SDL REQUIRED ) | ||
| target_link_libraries( ${ARG_NAME} PUBLIC ${SDL_LIBRARY} ) | ||
| target_compile_definitions( ${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL ) | ||
| target_link_libraries( ${ARG_NAME} PUBLIC X11 Math::Math ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for doing
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to install libadikted first and run export PKG_CONFIG_PATH=$PREFIX/${libdir}/pkgconfig && ldconfigI apologize for reopening the pull request.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, fixing mapslang compile issue can wait I'd rather have this PR merged sooner rather than later and invoking cmake from the root directory works just fine for now. I'll do a proper review when I get home from work tomorrow. Good work though, I appreciate it!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose a package interface named DKFans::ADiKtED and resolve the dependencies for parent directories too. |
||
| target_include_directories(${ARG_NAME} PUBLIC Math::Math | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/examples/${ARG_NAME}> | ||
| $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lib${TARGET_NAME}> | ||
| ${SDL_INCLUDE_DIR} | ||
| PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.) | ||
|
|
||
| # Directory name | ||
| set_target_properties( ${ARG_NAME} PROPERTIES FOLDER | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/examples" ) | ||
| add_test(${ARG_NAME} ${ARG_NAME}) | ||
| endfunction() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.