-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
47 lines (40 loc) · 1.77 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
cmake_minimum_required(VERSION 3.12)
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum macOS version" FORCE)
if(WIN32)
set(CMAKE_GENERATOR_PLATFORM "Win32" CACHE STRING "" FORCE) # force 32-bit build
endif()
project(MpqSimpleIO
VERSION 1.0
DESCRIPTION "Simple I/O for Diablo II MPQ files"
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(STORMLIB StormLib)
add_library(${STORMLIB} STATIC IMPORTED)
add_executable(${PROJECT_NAME} main.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} ${STORMLIB})
if(APPLE)
set_target_properties(${STORMLIB} PROPERTIES IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/StormLib/macos/libStormLib.a)
target_link_libraries(${PROJECT_NAME} bz2 z)
elseif(WIN32)
set(STORMLIB_DIR "${CMAKE_SOURCE_DIR}/StormLib/windows")
set(STORMLIB_DEBUG "${STORMLIB_DIR}/StormLibDAS.lib")
set(STORMLIB_RELEASE "${STORMLIB_DIR}/StormLibRAS.lib")
if(isMultiConfig)
set_target_properties(${STORMLIB} PROPERTIES IMPORTED_LOCATION "${STORMLIB_RELEASE}")
set_target_properties(${STORMLIB} PROPERTIES IMPORTED_LOCATION_DEBUG "${STORMLIB_DEBUG}")
else()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(STORMLIB_PATH STORMLIB_DEBUG)
else()
set(STORMLIB_PATH STORMLIB_RELEASE)
endif()
set_target_properties(${STORMLIB} PROPERTIES IMPORTED_LOCATION "${${STORMLIB_PATH}}")
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE STORMLIB_NO_AUTO_LINK)
target_compile_options(${PROJECT_NAME} PRIVATE /UUNICODE /U_UNICODE) # ANSI build
target_compile_options(${PROJECT_NAME} PRIVATE $<IF:$<CONFIG:Debug>,/MTd,/MT>) # fix LNK4098, StormLib uses MT for static libs
endif()