Skip to content

Commit eed0170

Browse files
author
Jon Daniel
committed
Add CMake build system and and updated README.md
1 parent 7bde84c commit eed0170

47 files changed

Lines changed: 589 additions & 97 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,43 @@
44
*.dll
55
*.def
66
*.exe
7-
/lib/slang*
8-
/mapslang/pkg/*
7+
*.so
8+
*.a
9+
*.pc
10+
*.log
11+
lib/slang*
12+
mapslang/pkg/*
13+
mapslang/mapslang
14+
mapslang/map
15+
map
916
.vs/
1017
.git
1118
/.cproject
1219
/.project
1320
/.settings/
14-
/tmp/
15-
/build/
21+
tmp/
22+
build/
23+
Makefile
24+
CMakeFiles/
25+
CMakeCache.txt
26+
cmake_install.cmake
27+
install_manifest.txt
28+
libadikted/CMakeFiles/
29+
libadikted/CMakeCache.txt
30+
libadikted/Makefile*
31+
libadikted/cmake_install.cmake
32+
libadikted/install_manifest.txt
33+
mapslang/CMakeFiles/
34+
mapslang/CMakeCache.txt
35+
mapslang/cmake_install.cmake
36+
mapslang/Makefile*
37+
mapslang/install_manifest.txt
38+
mapslang/map
39+
putemple
40+
puttrain
41+
putgems
42+
viewmap*
43+
./putemple
44+
./puttrain
45+
./putgems
46+
./viewmap*

CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
cmake_minimum_required( VERSION 3.1 )
2+
3+
project( ADiKtED LANGUAGES C )
4+
set(PROJECT_DESCRIPTION "Dungeon Keeper 1 map editor")
5+
6+
include(GNUInstallDirs)
7+
include(FindPkgConfig)
8+
9+
if( NOT CMAKE_BUILD_TYPE )
10+
set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
11+
endif()
12+
13+
set( CMAKE_C_STANDARD 99 )
14+
set( CMAKE_C_STANDARD_REQUIRED ON )
15+
16+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-switch" )
17+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic" )
18+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra" )
19+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror-implicit-function-declaration -Wno-conversion -Wno-traditional-conversion -Wno-sign-compare" )
20+
21+
# Add Math::Math
22+
include(cmake/FindMath.cmake)
23+
24+
# Add examples
25+
include(cmake/examples.cmake)
26+
option( ADIKTED_BUILD_EXAMPLES "Build ADiKtEd examples" ON )
27+
if( ADIKTED_BUILD_EXAMPLES )
28+
set(
29+
ADIKTED_EXAMPLES
30+
putgems
31+
puttrain
32+
viewmap
33+
putemple
34+
)
35+
36+
foreach( EXAMPLE ${ADIKTED_EXAMPLES} )
37+
add_example( ${EXAMPLE} )
38+
endforeach()
39+
endif()
40+
41+
add_subdirectory(libadikted)
42+
add_subdirectory(mapslang)
43+
44+
install( TARGETS ${ADIKTED_EXAMPLES} RUNTIME
45+
DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT binaries)

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Adikted Dungeon Keeper Map Editor
2+
3+
Note - there is now a manual available for ADiKtEd.
4+
It even includes a basic tutorial to quickly learn the program.
5+
A version of it is included within this distribution,
6+
called `dk_adikted_manual.htm`. You may wish to print this out.
7+
## Build
8+
9+
### Unix-like systems
10+
11+
#### CMake
12+
13+
Run
14+
`cmake --install-prefix=/usr . && make install`
15+
and copy the examples to the keeperfx directory
16+
17+
### Windows
18+
19+
#### make
20+
21+
Run `cd libadikted/ && make -f Makefile.win && cd mapslang && make -f Makefile.win`
22+
23+
Here's the Win32 version executable. Just put all the
24+
files in the same directory, edit map.ini as appropriate (you should
25+
change paths to your DK files; you can also change other parameters
26+
if you want), and run it.
27+
28+
## Usage
29+
30+
Run `map [mapfile] [-m <logfile>] [-v] [-r] [-n] [-s [mapfile]] [-q]`
31+
32+
When ADiKtEd saves a map, it will ask you what you wish to call it
33+
(unless you're not using quick save). I suggest you don't save
34+
directly over the Dungeon Keeper original levels, but keep it
35+
in the current directory until you're finished.
36+
Then, at end, save it on `map00001` to access it easily in the game.
37+
38+
You'll need a level script for your newly created level. You may be
39+
able to get by with the script which comes with the original level 1
40+
- ie just copy it and paste into TXT file of your new map - but
41+
if not, study the level scripts reference from `dk_scripting_ref.htm`.
42+
You can also try looking at the original DK and DD levels for examples.
43+
44+
Press F1 for help.
45+
46+
## TODO before final
47+
Fixations in room things parameters (height,other)
48+
Fixations in room corner graphics
49+
50+
## Author
51+
Jon Skeet, skeet@pobox.com
52+
53+
Dev-C++ IDE version,
54+
rewritten most of the code:
55+
Tomasz Lis

cmake/FindMath.cmake

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
include (CheckLibraryExists)
2+
set(Math_FOUND FALSE)
3+
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
4+
set(CMAKE_REQUIRED_QUIET ${Math_FIND_QUIETLY})
5+
6+
if(CMAKE_C_COMPILER_LOADED)
7+
include (CheckIncludeFile)
8+
include (CheckCSourceCompiles)
9+
elseif(CMAKE_CXX_COMPILER_LOADED)
10+
include (CheckIncludeFileCXX)
11+
include (CheckCXXSourceCompiles)
12+
else()
13+
message(FATAL_ERROR "FindMath only works if either C or CXX language is enabled")
14+
endif()
15+
16+
set(MATH_C_CXX_TEST_SOURCE [====[
17+
#include <math.h>
18+
19+
int main()
20+
{
21+
const double x = 7.3;
22+
ceil(x);
23+
acos(x);
24+
sin(x);
25+
sqrt(x);
26+
27+
return 0;
28+
}
29+
]====])
30+
31+
32+
if(CMAKE_C_COMPILER_LOADED)
33+
CHECK_INCLUDE_FILE("math.h" CMAKE_HAVE_MATH_H)
34+
else()
35+
CHECK_INCLUDE_FILE_CXX("math.h" CMAKE_HAVE_MATH_H)
36+
endif()
37+
38+
if(CMAKE_HAVE_MATH_H)
39+
set(CMAKE_HAVE_MATH_LIBRARY)
40+
41+
set(CMAKE_REQUIRED_LIBRARIES -lm)
42+
if(CMAKE_C_COMPILER_LOADED)
43+
CHECK_C_SOURCE_COMPILES("${MATH_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_LIBM)
44+
elseif(CMAKE_CXX_COMPILER_LOADED)
45+
CHECK_CXX_SOURCE_COMPILES("${MATH_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_LIBM)
46+
endif()
47+
48+
if(CMAKE_HAVE_LIBC_LIBM)
49+
set(CMAKE_MATH_LIBS_INIT ${CMAKE_REQUIRED_LIBRARIES})
50+
set(CMAKE_HAVE_MATH_LIBRARY 1)
51+
set(Math_FOUND TRUE)
52+
else()
53+
set(Math_FOUND FALSE)
54+
endif()
55+
56+
unset(CMAKE_REQUIRED_LIBRARIES)
57+
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
58+
59+
include(FindPackageHandleStandardArgs)
60+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Math DEFAULT_MSG Math_FOUND)
61+
62+
if(MATH_FOUND AND NOT TARGET Math::Math)
63+
add_library(Math::Math INTERFACE IMPORTED)
64+
65+
if(CMAKE_MATH_LIBS_INIT)
66+
set_property(TARGET Math::Math PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_MATH_LIBS_INIT}")
67+
endif()
68+
elseif(NOT MATH_FOUND)
69+
file(APPEND
70+
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
71+
"Determining if compiler accepts -lm failed with the following output:\n${_cmake_find_math_output}\n\n")
72+
message(SEND_ERROR "Required Math library not found!")
73+
endif()
74+
endif()
75+
76+
unset(_cmake_find_math_output)

cmake/examples.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function( add_example ARG_NAME )
2+
list( APPEND ARG_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/examples/${ARG_NAME}" )
3+
set( SOURCES "" )
4+
set( RESOURCES "" )
5+
foreach( DIR ${ARG_DIRECTORIES} )
6+
file( GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.h )
7+
list( APPEND SOURCES ${GLOB_SOURCES} )
8+
file( GLOB GLOB_RESOURCES ${DIR}/*.rc )
9+
list( APPEND RESOURCES ${GLOB_RESOURCES} )
10+
endforeach()
11+
add_executable( ${ARG_NAME} ${SOURCES} )
12+
target_link_libraries( ${ARG_NAME} PUBLIC adikted )
13+
find_package( SDL REQUIRED )
14+
target_link_libraries( ${ARG_NAME} PUBLIC ${SDL_LIBRARY} )
15+
target_compile_definitions( ${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL )
16+
target_link_libraries( ${ARG_NAME} PUBLIC X11 Math::Math )
17+
target_include_directories(${ARG_NAME} PUBLIC Math::Math
18+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/examples/${ARG_NAME}>
19+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/lib${TARGET_NAME}>
20+
${SDL_INCLUDE_DIR}
21+
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.)
22+
23+
# Directory name
24+
set_target_properties( ${ARG_NAME} PROPERTIES FOLDER
25+
"${CMAKE_CURRENT_SOURCE_DIR}/examples" )
26+
add_test(${ARG_NAME} ${ARG_NAME})
27+
endfunction()
28+
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/******************************************************************************/
22
/** @file putemple.c
3-
* ADiKtEd library example 4.
3+
* ADiKtEd library putemple example.
44
* @par Purpose:
55
* Demonstrates fast drawing routines and putting slabs with mouse.
66
* Also, shows how to draw ADiKtEd messages using DK font.
@@ -23,7 +23,7 @@
2323
#include <string.h>
2424
#include <SDL/SDL.h>
2525

26-
#include "../libadikted/adikted.h"
26+
#include "libadikted/adikted.h"
2727

2828
#define ONE_LOOP_DELAY 20
2929
/**
@@ -404,7 +404,7 @@ static void process_events()
404404
// contains error message.
405405
// Release the error message.
406406
message_release();
407-
message_info("example4 finished with map load error");
407+
message_info("putemple finished with map load error");
408408
reload_data=0;
409409
level_redraw=0;
410410
clip_view=0;
@@ -425,7 +425,7 @@ static void process_events()
425425
{
426426
// Release the error message.
427427
message_release();
428-
message_info("example4 finished with data files load error");
428+
message_info("putemple finished with data files load error");
429429
level_redraw=0;
430430
clip_view=0;
431431
done = 1;
@@ -493,7 +493,7 @@ int main (int argc, char *argv[])
493493
free_messages();
494494
return 2;
495495
}
496-
SDL_WM_SetCaption ("ADiKtEd Libray example 4", NULL);
496+
SDL_WM_SetCaption ("ADiKtEd Libray putemple example", NULL);
497497

498498
message_log("Preparing data structures");
499499
// create object for storing map

0 commit comments

Comments
 (0)