summary refs log tree commit diff
path: root/CMakeLists.txt
blob: 1b61e7812f9839fef086dd15547bb71143250e46 (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
cmake_minimum_required(VERSION 3.13)

project(WEP C)

find_package(SDL2 REQUIRED)

add_subdirectory(cards)
include_directories(cards)

if(NOT MSVC)
	add_compile_options(-Wall -Wextra -pedantic)
endif()

add_executable(sol MACOSX_BUNDLE sol.c)
add_executable(freecell MACOSX_BUNDLE freecell.c)

set_target_properties(
	sol freecell PROPERTIES
	MACOSX_BUNDLE_INFO_PLIST
	${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in
)
if(CMAKE_MACOSX_BUNDLE OR CMAKE_SYSTEM_NAME STREQUAL Darwin)
	set_target_properties(sol PROPERTIES OUTPUT_NAME Solitaire)
	set_target_properties(freecell PROPERTIES OUTPUT_NAME FreeCell)
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/CARDS.DLL)
	target_sources(sol PRIVATE CARDS.DLL)
	target_sources(freecell PRIVATE CARDS.DLL)
	set_target_properties(sol freecell PROPERTIES RESOURCE CARDS.DLL)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/FREECELL.EXE)
	target_sources(freecell PRIVATE FREECELL.EXE)
	set_target_properties(freecell PROPERTIES RESOURCE "CARDS.DLL;FREECELL.EXE")
endif()

# Workaround possible bugs in SDL2Config.cmake
if(MINGW)
	target_link_libraries(sol mingw32) # -lmingw32 -lSDL2main -lSDL2 in that order.
	target_link_libraries(freecell mingw32)
	set_target_properties(sol PROPERTIES WIN32_EXECUTABLE 1) # -mwindows
	set_target_properties(freecell PROPERTIES WIN32_EXECUTABLE 1)
endif()

target_link_libraries(sol cards SDL2::SDL2main SDL2::SDL2)
target_link_libraries(freecell cards SDL2::SDL2main SDL2::SDL2)

# Avoid conflicting with SOL.EXE, FREECELL.EXE on Windows
if(WIN32)
	set_target_properties(sol PROPERTIES OUTPUT_NAME wepsol)
	set_target_properties(freecell PROPERTIES OUTPUT_NAME wepfreecell)
endif()

add_executable(exe2ico EXCLUDE_FROM_ALL tools/exe2ico.c)
target_link_libraries(exe2ico SDL2::SDL2)

install(TARGETS sol freecell BUNDLE DESTINATION /Applications)