if(APPLE)
	enable_language(OBJCXX)
endif()

if(NOT APPLE AND NOT WIN32)
	find_package(PkgConfig REQUIRED)
	pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
endif()

add_library(
	NostalgiaStudio
		configio.cpp
		editor.cpp
		module.cpp
		project.cpp
		task.cpp
		undostack.cpp
		widget.cpp
		window.cpp
		filedialog_gtk.cpp
		$<$<BOOL:${APPLE}>:filedialog_mac.mm>
)

if(NOT MSVC)
	target_compile_options(NostalgiaStudio PUBLIC -Wsign-conversion)
endif()

install(TARGETS NostalgiaStudio
        LIBRARY DESTINATION ${NOSTALGIA_DIST_LIB}/nostalgia)

generate_export_header(NostalgiaStudio)
target_include_directories(NostalgiaStudio PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

find_package(imgui REQUIRED)

include_directories(
	SYSTEM
		${GTK3_INCLUDE_DIRS}
)

target_link_libraries(
	NostalgiaStudio PUBLIC
		imgui::imgui
		${GTK3_LIBRARIES}
		OxEvent
		NostalgiaCore
)

install(
	FILES
		configio.hpp
		context.hpp
		editor.hpp
		filedialog.hpp
		module.hpp
		project.hpp
		task.hpp
        undostack.hpp
		widget.hpp
		window.hpp
		${CMAKE_CURRENT_BINARY_DIR}/nostalgiastudio_export.h
	DESTINATION
		include/nostalgia/studio/lib
)
