view dep/animia/CMakeLists.txt @ 156:cdf79282d647

dep/animia: add VERY early x11 window stuff
author Paper <mrpapersonic@gmail.com>
date Wed, 15 Nov 2023 18:04:04 -0500
parents d2bbb5773616
children 80d6b28eb29f
line wrap: on
line source

cmake_minimum_required(VERSION 3.9)
project(animia LANGUAGES CXX)
set(SRC_FILES
	# any non-platform-specific files go here
	src/animia.cc
	src/player.cc
	src/util.cc
	src/strategist.cc
	src/fd.cc
	src/win.cc
)

set(LIBRARIES)

set(INCLUDE_DIRS
	include
)

set(DEFINES)

# FD
if(LINUX)
	list(APPEND DEFINES LINUX)
	list(APPEND SRC_FILES
		# linux
		src/fd/linux.cc
	)
elseif(APPLE) # this won't run on Linux
	list(APPEND DEFINES MACOSX)
	list(APPEND SRC_FILES
		# xnu stuff
		src/fd/xnu.cc
	)
elseif(WIN32)
	list(APPEND DEFINES WIN32)
	list(APPEND SRC_FILES
		# win32
		src/fd/win32.cc
	)
endif()

# Windows
if(WIN32)
	list(APPEND SRC_FILES
		src/win/win32.cc
		src/util/win32.cc
	)
elseif(APPLE)
	enable_language(OBJCXX)
	list(APPEND SRC_FILES
		src/win/quartz.mm
	)
	find_library(FOUNDATION_LIBRARY Foundation)
	find_library(COREGRAPHICS_LIBRARY CoreGraphics)
	find_library(APPKIT_LIBRARY AppKit)
	list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY})
else()
	find_package(X11::X11)
	if (X11_FOUND)
		list(APPEND DEFINES X11)
		list(APPEND SRC_FILES
			src/win/x11.cc
		)
		list(APPEND INCLUDE_DIRS
			${X11_INCLUDE_DIR}
		)
		list(APPEND LIBRARIES
			${X11_LIBRARIES}
		)
	endif()
endif()

add_library(animia SHARED ${SRC_FILES})
set_target_properties(animia PROPERTIES
	PUBLIC_HEADER include/animia.h
	CXX_STANDARD 17
)

if(WIN32)
	target_compile_definitions(animia PUBLIC WIN32)
elseif(LINUX)
	target_compile_definitions(animia PUBLIC LINUX)
elseif(UNIX)
	if(APPLE)
		target_compile_definitions(animia PUBLIC MACOSX)
	endif()
	target_compile_definitions(animia PUBLIC UNIX)
endif()

target_include_directories(animia PRIVATE include)
target_link_libraries(animia PUBLIC ${LIBRARIES})