diff --git a/CMakeLists.txt b/CMakeLists.txt index e3ff16b..6f68b63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(csnake VERSION 1.0 LANGUAGES C) +project(csnake VERSION 1.1 LANGUAGES C) if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) message(FATAL_ERROR "In-source builds are not allowed.") @@ -16,6 +16,9 @@ add_executable(csnake set_target_properties(csnake PROPERTIES C_STANDARD 11) set_target_properties(csnake PROPERTIES C_EXTENSIONS FALSE) +if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + target_link_libraries(csnake pthread) +endif() target_include_directories(csnake PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) set(SIZE 10 CACHE STRING "Size of game field") diff --git a/Makefile b/Makefile index c374147..d13877c 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ OBJDIR = obj SRC = main.c screen.c input.c player.c platform.c sleep.c OBJ = $(addprefix $(OBJDIR)/,$(SRC:.c=.o)) +DEFLDFLAGS = $(shell if echo "" | cc -E -dM -xc - | grep __FreeBSD__ > /dev/null 2>&1; then echo "-lpthread"; fi) + all: $(OUT) obj: @@ -16,7 +18,7 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.c $(CC) -c -o $@ $< $(CFLAGS) $(INCLUDE) $(OUT): obj $(OBJ) - $(CC) -o $@ $(OBJ) $(LDFLAGS) + $(CC) -o $@ $(OBJ) $(LDFLAGS) $(DEFLDFLAGS) clean: $(RM) $(OUT) $(OBJDIR)/*