summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--CMakeLists.txt25
-rw-r--r--Makefile26
-rwxr-xr-xconfigure8
-rw-r--r--sol.c5
5 files changed, 30 insertions, 39 deletions
diff --git a/.gitignore b/.gitignore
index cf601f3..4629025 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,4 @@
-*.o
 CARDS.DLL
 FREECELL.EXE
 SOL.EXE
-config.mk
-freecell
-sol
+build/
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..926fed0
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(WEP)
+
+find_package(SDL2 REQUIRED)
+include_directories(${SDL2_INCLUDE_DIRS})
+
+if(NOT MSVC)
+	add_compile_options(-Wall -Wextra -pedantic)
+endif()
+
+include_directories(cards)
+add_library(cards STATIC cards/cards.c)
+
+add_executable(sol sol.c)
+add_executable(freecell freecell.c)
+
+target_link_libraries(sol cards SDL2::SDL2 SDL2::SDL2main)
+target_link_libraries(freecell cards SDL2::SDL2 SDL2::SDL2main)
+
+# 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()
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 03bb0ad..0000000
--- a/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-CFLAGS += -std=c99 -Wall -Wextra -Wpedantic
-CFLAGS += -Icards
-
-include config.mk
-
-BINS = freecell sol
-OBJS = ${BINS:%=%.o}
-
-all: ${BINS}
-
-${BINS}: cards/cards.o
-
-.o:
-	${CC} ${LDFLAGS} $< cards/cards.o ${LDLIBS} -o $@
-
-${OBJS} cards/cards.o: cards/cards.h
-
-${OBJS}: asset.h stack.h
-
-sol.o: layout.h
-
-cards/cards.h:
-	git submodule update --init
-
-clean:
-	rm -f ${BINS} *.o cards/*.o
diff --git a/configure b/configure
deleted file mode 100755
index ba1718c..0000000
--- a/configure
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-set -eu
-cflags=$(pkg-config --cflags sdl2)
-ldlibs=$(pkg-config --libs sdl2)
-cat > config.mk << EOF
-CFLAGS += ${cflags}
-LDLIBS += ${ldlibs}
-EOF
diff --git a/sol.c b/sol.c
index 5622395..48a61a2 100644
--- a/sol.c
+++ b/sol.c
@@ -320,7 +320,10 @@ static void err(const char *title) {
 	exit(EXIT_FAILURE);
 }
 
-int main(void) {
+int main(int argc, char *argv[]) {
+	(void)argc;
+	(void)argv;
+
 	if (SDL_Init(SDL_INIT_VIDEO) < 0) err("SDL_Init");
 	atexit(SDL_Quit);