2009-09-13 18:02:46 -06:00
# don't use this file directly. use the one in the root folder of the project
2010-05-26 04:24:45 -06:00
PROJECT ( dfhack-library )
2011-03-16 00:35:08 -06:00
cmake_minimum_required ( VERSION 2.8 )
2010-05-26 04:24:45 -06:00
SET ( CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /CMake/Modules )
if ( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
2011-03-17 17:07:40 -06:00
message ( FATAL_ERROR "In-source builds are not allowed." )
2011-03-16 00:35:08 -06:00
endif ( )
2010-05-26 04:24:45 -06:00
IF ( NOT DEFINED CMAKE_BUILD_TYPE )
SET ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2010-05-26 04:24:45 -06:00
include_directories ( ${ CMAKE_SOURCE_DIR } /library/include/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/shm/ )
2011-02-28 23:50:56 -07:00
include_directories ( ${ CMAKE_SOURCE_DIR } /library/depends/md5/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/depends/tinyxml/ )
2010-05-26 04:24:45 -06:00
include_directories ( ${ CMAKE_SOURCE_DIR } /library/depends/argstream/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/private/ )
2009-09-13 18:02:46 -06:00
2010-08-30 21:32:40 -06:00
SET ( PROJECT_HDRS_INTERNAL
p r i v a t e / C o n t e x t S h a r e d . h
p r i v a t e / I n t e r n a l . h
2011-02-23 02:02:14 -07:00
p r i v a t e / S H M P r o c e s s . h
2011-02-23 03:26:33 -07:00
p r i v a t e / L i n u x P r o c e s s . h
2011-02-23 04:08:30 -07:00
p r i v a t e / P r o c e s s F a c t o r y . h
2011-02-23 13:55:07 -07:00
p r i v a t e / M i c r o s o f t S T L . h
2010-08-30 21:32:40 -06:00
)
2009-10-26 15:50:08 -06:00
SET ( PROJECT_HDRS
2010-08-30 21:32:40 -06:00
i n c l u d e / D F H a c k . h
i n c l u d e / d f h a c k / D F C o n t e x t . h
i n c l u d e / d f h a c k / D F C o n t e x t M a n a g e r . h
2010-05-25 22:48:23 -06:00
i n c l u d e / d f h a c k / D F E r r o r . h
2010-08-30 21:32:40 -06:00
i n c l u d e / d f h a c k / D F E x p o r t . h
i n c l u d e / d f h a c k / D F G l o b a l . h
i n c l u d e / d f h a c k / D F I n t e g e r s . h
i n c l u d e / d f h a c k / D F M i s c U t i l s . h
i n c l u d e / d f h a c k / D F M o d u l e . h
i n c l u d e / d f h a c k / D F P r a g m a . h
2010-05-25 22:48:23 -06:00
i n c l u d e / d f h a c k / D F P r o c e s s . h
2010-08-30 21:32:40 -06:00
i n c l u d e / d f h a c k / D F P r o c e s s E n u m e r a t o r . h
2010-05-25 22:48:23 -06:00
i n c l u d e / d f h a c k / D F T i l e T y p e s . h
i n c l u d e / d f h a c k / D F T y p e s . h
i n c l u d e / d f h a c k / D F V e c t o r . h
2010-08-30 21:32:40 -06:00
i n c l u d e / d f h a c k / V e r s i o n I n f o F a c t o r y . h
i n c l u d e / d f h a c k / V e r s i o n I n f o . h
2010-05-26 04:24:45 -06:00
i n c l u d e / d f h a c k / m o d u l e s / B u i l d i n g s . h
i n c l u d e / d f h a c k / m o d u l e s / C o n s t r u c t i o n s . h
i n c l u d e / d f h a c k / m o d u l e s / C r e a t u r e s . h
i n c l u d e / d f h a c k / m o d u l e s / G u i . h
i n c l u d e / d f h a c k / m o d u l e s / I t e m s . h
i n c l u d e / d f h a c k / m o d u l e s / M a p s . h
i n c l u d e / d f h a c k / m o d u l e s / M a t e r i a l s . h
i n c l u d e / d f h a c k / m o d u l e s / T r a n s l a t i o n . h
i n c l u d e / d f h a c k / m o d u l e s / V e g e t a t i o n . h
i n c l u d e / d f h a c k / m o d u l e s / W i n d o w I O . h
i n c l u d e / d f h a c k / m o d u l e s / W o r l d . h
2009-10-26 15:50:08 -06:00
)
2010-08-12 18:35:10 -06:00
SET ( PROJECT_C_HDRS
2010-08-30 21:32:40 -06:00
i n c l u d e / D F H a c k _ C . h
2010-08-12 18:35:10 -06:00
i n c l u d e / d f h a c k - c / D F T y p e s _ C . h
i n c l u d e / d f h a c k - c / D F C o n t e x t _ C . h
2010-08-30 21:32:40 -06:00
i n c l u d e / d f h a c k - c / m o d u l e s / B u i l d i n g s _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / C o n s t r u c t i o n s _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / C r e a t u r e s _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / G u i _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / I t e m s _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / M a p s _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / M a t e r i a l s _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / P o s i t i o n _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / T r a n s l a t i o n _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / V e g e t a t i o n _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / W i n d o w I O _ C . h
i n c l u d e / d f h a c k - c / m o d u l e s / W o r l d _ C . h
2010-08-12 18:35:10 -06:00
)
2009-09-13 18:02:46 -06:00
SET ( PROJECT_SRCS
2010-08-20 06:10:05 -06:00
V e r s i o n I n f o . c p p
V e r s i o n I n f o F a c t o r y . c p p
2010-05-23 15:06:10 -06:00
D F C o n t e x t M a n a g e r . c p p
D F C o n t e x t . c p p
2010-11-17 12:50:50 -07:00
D F T i l e T y p e s . c p p
2010-05-27 21:18:32 -06:00
D F P r o c e s s E n u m e r a t o r . c p p
2010-05-26 04:24:45 -06:00
C o n t e x t S h a r e d . c p p
2011-02-23 02:02:14 -07:00
D F P r o c e s s - S H M . c p p
2011-02-23 13:55:07 -07:00
M i c r o s o f t S T L . c p p
2010-04-02 19:52:46 -06:00
d e p e n d s / m d 5 / m d 5 . c p p
d e p e n d s / m d 5 / m d 5 w r a p p e r . c p p
d e p e n d s / t i n y x m l / t i n y s t r . c p p
d e p e n d s / t i n y x m l / t i n y x m l . c p p
d e p e n d s / t i n y x m l / t i n y x m l e r r o r . c p p
d e p e n d s / t i n y x m l / t i n y x m l p a r s e r . c p p
2010-05-26 04:24:45 -06:00
m o d u l e s / B u i l d i n g s . c p p
m o d u l e s / C o n s t r u c t i o n s . c p p
2010-04-02 19:52:46 -06:00
m o d u l e s / C r e a t u r e s . c p p
m o d u l e s / G u i . c p p
2010-05-02 02:35:23 -06:00
m o d u l e s / I t e m s . c p p
2010-04-02 19:52:46 -06:00
m o d u l e s / M a p s . c p p
m o d u l e s / M a t e r i a l s . c p p
m o d u l e s / P o s i t i o n . c p p
2010-04-06 09:11:58 -06:00
m o d u l e s / T r a n s l a t i o n . c p p
2010-04-07 04:49:37 -06:00
m o d u l e s / V e g e t a t i o n . c p p
2010-05-26 04:24:45 -06:00
m o d u l e s / W o r l d . c p p
2010-08-12 18:35:10 -06:00
)
SET ( PROJECT_C_SRCS
D F C o n t e x t _ C . c p p
D F T y p e s _ C . c p p
2010-04-30 15:04:17 -06:00
2010-05-25 14:40:24 -06:00
m o d u l e s / B u i l d i n g s _ C . c p p
m o d u l e s / C o n s t r u c t i o n s _ C . c p p
m o d u l e s / C r e a t u r e s _ C . c p p
2010-05-26 04:24:45 -06:00
m o d u l e s / G u i _ C . c p p
2010-05-25 14:40:24 -06:00
m o d u l e s / I t e m s _ C . c p p
2010-05-26 04:24:45 -06:00
m o d u l e s / M a p s _ C . c p p
m o d u l e s / P o s i t i o n _ C . c p p
m o d u l e s / M a t e r i a l s _ C . c p p
m o d u l e s / T r a n s l a t i o n _ C . c p p
m o d u l e s / V e g e t a t i o n _ C . c p p
2010-05-26 13:51:39 -06:00
m o d u l e s / W i n d o w I O _ C . c p p
m o d u l e s / W o r l d _ C . c p p
2009-09-13 18:02:46 -06:00
)
2009-11-16 20:19:13 -07:00
SET ( PROJECT_HDRS_LINUX
)
SET ( PROJECT_HDRS_WINDOWS
2010-05-26 00:42:09 -06:00
i n c l u d e / d f h a c k / D F s t d i n t _ w i n . h
2009-11-16 20:19:13 -07:00
)
SET ( PROJECT_SRCS_LINUX
D F P r o c e s s - l i n u x . c p p
2011-02-23 03:26:33 -07:00
D F P r o c e s s - l i n u x - b a s e . c p p
2009-12-22 14:19:39 -07:00
D F P r o c e s s - l i n u x - S H M . c p p
2010-02-15 16:04:15 -07:00
D F P r o c e s s - l i n u x - w i n e . c p p
2010-05-26 04:24:45 -06:00
m o d u l e s / W i n d o w I O - l i n u x . c p p
2009-11-16 20:19:13 -07:00
)
SET ( PROJECT_SRCS_WINDOWS
D F P r o c e s s - w i n d o w s . c p p
2010-01-10 23:27:59 -07:00
D F P r o c e s s - w i n d o w s - S H M . c p p
2010-05-26 04:24:45 -06:00
m o d u l e s / W i n d o w I O - w i n d o w s . c p p
2009-11-16 20:19:13 -07:00
)
IF ( UNIX )
LIST ( APPEND PROJECT_HDRS ${ PROJECT_HDRS_LINUX } )
LIST ( APPEND PROJECT_SRCS ${ PROJECT_SRCS_LINUX } )
2011-03-16 00:35:08 -06:00
ELSE ( )
2009-11-16 20:19:13 -07:00
LIST ( APPEND PROJECT_HDRS ${ PROJECT_HDRS_WINDOWS } )
LIST ( APPEND PROJECT_SRCS ${ PROJECT_SRCS_WINDOWS } )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2009-11-16 20:19:13 -07:00
2010-08-30 11:36:40 -06:00
IF ( BUILD_DFHACK_C_BINDINGS )
2010-08-12 18:35:10 -06:00
LIST ( APPEND PROJECT_HDRS ${ PROJECT_C_HDRS } )
LIST ( APPEND PROJECT_SRCS ${ PROJECT_C_SRCS } )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2010-08-12 18:35:10 -06:00
2009-10-26 15:50:08 -06:00
SET_SOURCE_FILES_PROPERTIES ( ${ PROJECT_HDRS } PROPERTIES HEADER_FILE_ONLY TRUE )
LIST ( APPEND PROJECT_SRCS ${ PROJECT_HDRS } )
2010-04-26 16:12:22 -06:00
# Are we 64bit? (Damn you, ptrace()!)
IF ( CMAKE_SIZEOF_VOID_P MATCHES 4 )
SET ( HAVE_64_BIT 0 )
2011-03-16 00:35:08 -06:00
ELSE ( )
2010-04-26 16:12:22 -06:00
SET ( HAVE_64_BIT 1 )
2011-03-16 00:35:08 -06:00
ENDIF ( )
2009-10-29 18:56:40 -06:00
2010-05-26 04:24:45 -06:00
CONFIGURE_FILE ( ${ CMAKE_SOURCE_DIR } /library/config.h.cmake ${ CMAKE_SOURCE_DIR } /library/private/config.h )
2009-10-29 18:56:40 -06:00
2011-02-28 23:50:56 -07:00
ADD_DEFINITIONS ( -DBUILD_DFHACK_LIB -DTIXML_USE_STL )
2009-10-29 18:56:40 -06:00
2009-09-13 18:02:46 -06:00
IF ( UNIX )
add_definitions ( -DLINUX_BUILD )
2009-10-29 18:56:40 -06:00
add_definitions ( -DUSE_CONFIG_H )
2009-12-12 12:52:30 -07:00
find_library ( X11_LIBRARY X11 )
2010-05-01 18:38:18 -06:00
SET ( CMAKE_CXX_FLAGS_DEBUG "-g -Wall" )
2010-02-25 15:43:37 -07:00
SET ( CMAKE_CXX_FLAGS "-fvisibility=hidden" )
2010-08-20 06:10:05 -06:00
2011-03-17 17:07:40 -06:00
SET ( PROJECT_LIBS ${ X11_LIBRARY } rt )
2011-03-16 00:35:08 -06:00
ELSE ( )
2011-02-17 17:14:16 -07:00
IF ( MSVC )
SET ( PROJECT_LIBS psapi ${ CMAKE_SOURCE_DIR } /library/depends/ntdll/ntdll.lib )
2011-03-16 00:35:08 -06:00
ELSE ( )
2011-02-17 17:14:16 -07:00
SET ( PROJECT_LIBS psapi ntdll )
2011-03-16 00:35:08 -06:00
ENDIF ( )
ENDIF ( )
2009-09-13 18:02:46 -06:00
ADD_LIBRARY ( dfhack SHARED ${ PROJECT_SRCS } )
2009-10-23 12:05:42 -06:00
2009-12-12 12:52:30 -07:00
SET_TARGET_PROPERTIES ( dfhack PROPERTIES DEBUG_POSTFIX "-debug" )
2009-10-23 12:05:42 -06:00
2009-10-29 18:56:40 -06:00
TARGET_LINK_LIBRARIES ( dfhack ${ PROJECT_LIBS } )
2011-03-16 00:35:08 -06:00
ADD_CUSTOM_COMMAND ( TARGET dfhack POST_BUILD
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y $ { C M A K E _ S O U R C E _ D I R } / M e m o r y . x m l $ { C M A K E _ B I N A R Y _ D I R } / b i n / $ { C M A K E _ C F G _ I N T D I R } / )
2011-03-17 17:07:40 -06:00
install ( TARGETS dfhack
L I B R A R Y D E S T I N A T I O N $ { D F H A C K _ L I B R A R Y _ D E S T I N A T I O N }
R U N T I M E D E S T I N A T I O N $ { D F H A C K _ L I B R A R Y _ D E S T I N A T I O N } ) #linux: lib
install ( FILES ${ CMAKE_SOURCE_DIR } /Memory.xml
D E S T I N A T I O N $ { D F H A C K _ D A T A _ D E S T I N A T I O N } ) #linux: share/dfhack
if ( WIN32 )
install ( TARGETS dfhack
A R C H I V E D E S T I N A T I O N $ { D F H A C K _ D E V L I B _ D E S T I N A T I O N } )
endif ( )
install ( DIRECTORY ${ CMAKE_SOURCE_DIR } /library/include/
D E S T I N A T I O N $ { D F H A C K _ I N C L U D E S _ D E S T I N A T I O N }
F I L E S _ M A T C H I N G P A T T E R N " * . h " ) #linux: include