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 )
cmake_minimum_required ( VERSION 2.6 )
SET ( CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /CMake/Modules )
# disable warning, autosearch
if ( COMMAND cmake_policy )
cmake_policy ( SET CMP0003 NEW )
endif ( COMMAND cmake_policy )
if ( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
message ( SEND_ERROR "In-source builds are not allowed." )
endif ( "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}" )
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." )
ENDIF ( NOT DEFINED CMAKE_BUILD_TYPE )
SET ( LIBRARY_OUTPUT_PATH ${ CMAKE_SOURCE_DIR } /output CACHE PATH "Output directory for the dfhack library" )
SET ( EXECUTABLE_OUTPUT_PATH ${ CMAKE_SOURCE_DIR } /output CACHE PATH "Output directory for the dfhack tools" )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/include/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/shm/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/depends/md5/ )
include_directories ( ${ CMAKE_SOURCE_DIR } /library/depends/tinyxml/ )
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
)
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 / P o s i 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 / 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
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
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 } )
ELSE ( UNIX )
LIST ( APPEND PROJECT_HDRS ${ PROJECT_HDRS_WINDOWS } )
LIST ( APPEND PROJECT_SRCS ${ PROJECT_SRCS_WINDOWS } )
ENDIF ( UNIX )
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 } )
2010-08-30 11:36:40 -06:00
ENDIF ( BUILD_DFHACK_C_BINDINGS )
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 } )
2009-10-31 12:18:59 -06:00
SET ( MEMXML_DATA_PATH . CACHE PATH "search path for Memory.xml" )
2009-10-29 18:56:40 -06:00
# OPTION( VARIABLE "Description" Initial state)
#OPTION( WITH_FOO "Enable FOO support" ON )
#OPTION( WITH_BAR "Enable BAR component" OFF )
2010-08-20 06:10:05 -06:00
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 )
ELSE ( CMAKE_SIZEOF_VOID_P MATCHES 4 )
SET ( HAVE_64_BIT 1 )
ENDIF ( CMAKE_SIZEOF_VOID_P MATCHES 4 )
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
2010-04-30 14:25:12 -06:00
ADD_DEFINITIONS ( -DBUILD_DFHACK_LIB )
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
2010-04-02 19:52:46 -06:00
SET ( PROJECT_LIBS ${ X11_LIBRARY } rt ) #dfhack-md5 dfhack-tixml
2009-09-13 18:02:46 -06:00
ELSE ( UNIX )
2010-04-02 19:52:46 -06:00
SET ( PROJECT_LIBS psapi )
2009-09-13 18:02:46 -06:00
ENDIF ( UNIX )
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 } )
2010-08-12 18:23:38 -06:00
if ( MSVC )
# This is a MSVC hack used for copying files into the target directory
# of build target set in MSVC.
# It exploits the fact that MSVC has some variables in .vcproj files, much like cmake does here.
#
# So, $(TargetDir) is ignored by cmake, and replaced with the actual output directory by MSVC
2010-09-22 10:20:55 -06:00
ADD_CUSTOM_COMMAND ( TARGET dfhack
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 } / d a t a / M e m o r y - n g . x m l " $ ( T a r g e t D i r ) / M e m o r y . x m l "
M A I N _ D E P E N D E N C Y $ { C M A K E _ S O U R C E _ D I R } / d a t a / M e m o r y - n g . x m l
2010-08-12 18:23:38 -06:00
)
2010-09-22 10:20:55 -06:00
ADD_CUSTOM_COMMAND ( TARGET dfhack
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 } / C o m p i l e . h t m l " $ ( T a r g e t D i r ) / C o m p i l e . h t m l "
M A I N _ D E P E N D E N C Y $ { C M A K E _ S O U R C E _ D I R } / C o m p i l e . h t m l
2010-08-13 15:25:14 -06:00
)
2010-09-22 10:20:55 -06:00
ADD_CUSTOM_COMMAND ( TARGET dfhack
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 } / R e a d m e . h t m l " $ ( T a r g e t D i r ) / R e a d m e . h t m l "
M A I N _ D E P E N D E N C Y $ { C M A K E _ S O U R C E _ D I R } / R e a d m e . h t m l
2010-08-13 15:25:14 -06:00
)
2010-09-22 10:20:55 -06:00
ADD_CUSTOM_COMMAND ( TARGET dfhack
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 } / L I C E N S E " $ ( T a r g e t D i r ) / L I C E N S E . t x t "
M A I N _ D E P E N D E N C Y $ { C M A K E _ S O U R C E _ D I R } / L I C E N S E
2010-08-15 16:45:02 -06:00
)
2010-08-12 18:23:38 -06:00
else ( MSVC )
# Just put the file in the output directory on Linux and Mac
2010-08-15 16:45:02 -06:00
configure_file ( ${ CMAKE_SOURCE_DIR } /data/Memory-ng.xml ${ DATA_OUTPUT_PATH } /Memory.xml COPYONLY )
2010-08-13 15:25:14 -06:00
configure_file ( ${ CMAKE_SOURCE_DIR } /Compile.html ${ DATA_OUTPUT_PATH } /Compile.html COPYONLY )
configure_file ( ${ CMAKE_SOURCE_DIR } /Readme.html ${ DATA_OUTPUT_PATH } /Readme.html COPYONLY )
2010-08-15 16:45:02 -06:00
configure_file ( ${ CMAKE_SOURCE_DIR } /LICENSE ${ DATA_OUTPUT_PATH } /LICENSE.txt COPYONLY )
2010-08-12 18:23:38 -06:00
endif ( MSVC )
2009-10-29 18:56:40 -06:00
IF ( UNIX )
install ( TARGETS dfhack LIBRARY DESTINATION lib )
install ( FILES ${ CMAKE_SOURCE_DIR } /output/Memory.xml DESTINATION share/dfhack )
2010-08-30 21:32:40 -06:00
install ( DIRECTORY ${ CMAKE_SOURCE_DIR } /library/include/ DESTINATION include FILES_MATCHING PATTERN "*.h" )
2009-10-29 18:56:40 -06:00
ENDIF ( UNIX )