summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorPetr Mrázek2009-11-29 23:55:30 +0000
committerPetr Mrázek2009-11-29 23:55:30 +0000
commit62fef6a46a82b2179ee6f0b2683edde8d10a58dc (patch)
tree0a1547f4480bfc553f20abd5372051c9fa9ceb21 /CMakeLists.txt
parenta752c7dee85158b6d803c26af8e9c5c3c0828a02 (diff)
downloadstonesense-62fef6a46a82b2179ee6f0b2683edde8d10a58dc.tar.gz
stonesense-62fef6a46a82b2179ee6f0b2683edde8d10a58dc.tar.bz2
stonesense-62fef6a46a82b2179ee6f0b2683edde8d10a58dc.tar.xz
got rid of some mingw32 hacks, windows icon resource now works with mingw32 and msvc. Set your system-wide paths right and don't hardcode them in the .bat files.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt39
1 files changed, 28 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 84f0b4c..45af3a9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,6 @@ ENDIF(NOT DEFINED CMAKE_BUILD_TYPE)
SET( EXECUTABLE_OUTPUT_PATH ${stonesense_SOURCE_DIR} CACHE PATH "Output directory for stonesense, default is root" )
include_directories (
- ${include_directories}
${CMAKE_SOURCE_DIR}/dfhack/library/
${CMAKE_SOURCE_DIR}/dfhack/library/md5/
${CMAKE_SOURCE_DIR}/dfhack/library/tinyxml
@@ -66,6 +65,30 @@ SET(PROJECT_SRCS
main.cpp
)
+
+# Under Windows, we also include a resource file to the build
+if(WIN32)
+ # Make sure that the resource file is seen as an RC file to be compiled with a resource compiler, not a C++ compiler
+ set_source_files_properties(${CMAKE_SOURCE_DIR}/res.rc LANGUAGE RC)
+ # Add the resource file to the list of sources
+ list(APPEND PROJECT_SRCS ${CMAKE_SOURCE_DIR}/res.rc)
+ # For MinGW, we have to change the compile flags
+ if(MINGW)
+ # resource compilation for mingw
+ set(CMAKE_RC_COMPILER_INIT windres)
+ ENABLE_LANGUAGE(RC)
+ SET(CMAKE_RC_COMPILE_OBJECT
+ "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> <SOURCE>")
+ set(RC_CFLAGS "-DMINGW -Ocoff")
+ # If any sort of debugging is being enabled, add a _DEBUG define to the flags for the resource compiler
+ #if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+ # set(RC_CFLAGS "${RC_CFLAGS} -D_DEBUG")
+ #endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+ set_source_files_properties(${CMAKE_SOURCE_DIR}/res.rc COMPILE_FLAGS "${RC_CFLAGS}")
+ # For anything else, assumingly Visual Studio at this point, use a different set of compile flags
+ endif(MINGW)
+endif(WIN32)
+
#linux
IF(UNIX)
@@ -85,6 +108,7 @@ IF(UNIX)
SET(PROJECT_LIBS ${ALLEGRO_LIBRARIES} ${PNG_LIBRARIES} ${PROJECT_LIBS})
ADD_EXECUTABLE(stonesense ${PROJECT_SRCS} ${PLATFORM_SRC})
TARGET_LINK_LIBRARIES(stonesense ${PROJECT_LIBS})
+
# windows
ELSE(UNIX)
add_definitions(-DBUILD_DFHACK_LIB)
@@ -94,18 +118,11 @@ ELSE(UNIX)
)
# use local allegro
# MinGW is broken. doesn't link properly for some reason.
+
IF(MINGW)
- # resource compilation for mingw
-
add_definitions(-DALLEGRO_MINGW32)
- SET(PROJECT_LIBS alleg42 psapi mingw32 libpng ${CMAKE_CURRENT_BINARY_DIR}/res_rc.obj)
- SET(PROJECT_SRCS ${PROJECT_SRCS} ${CMAKE_SOURCE_DIR}/res.rc)
- #ADD_CUSTOM_COMMAND actually seems to mean DO_ABSOLUTELY_NOTHING
- ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/res_rc.obj
- COMMAND c:/MinGW/bin/windres.exe
- -i${CMAKE_SOURCE_DIR}/res.rc
- -o ${CMAKE_CURRENT_BINARY_DIR}/res_rc.obj)
- include_directories (
+ SET(PROJECT_LIBS alleg42 psapi mingw32 libpng)
+ include_directories (
${include_directories}
${CMAKE_SOURCE_DIR}/allegro-mingw-4.2.2/include
)