if(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
	# enable warnings
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunsafe-buffer-usage")
endif()

add_library(
	OxFS
		src/filestore/filestoretemplate.cpp
		src/filesystem/filelocation.cpp
		src/filesystem/pathiterator.cpp
		src/filesystem/directory.cpp
		src/filesystem/filesystem.cpp
		src/filesystem/passthroughfs.cpp
)

if(NOT MSVC)
	target_compile_options(OxFS PRIVATE -Wsign-conversion)
endif()

if(NOT OX_BARE_METAL)
	set_property(
		TARGET
			OxFS
		PROPERTY
			POSITION_INDEPENDENT_CODE ON
	)
endif()

target_link_libraries(
	OxFS PUBLIC
		OxMetalClaw
)

target_include_directories(
	OxFS PUBLIC
		include
)

install(
	DIRECTORY
		include/ox
	DESTINATION
		include
)

if(NOT OX_BARE_METAL)
	add_executable(
		oxfs-tool
			src/tool.cpp
	)

	target_link_libraries(
		oxfs-tool
			OxFS
	)

	install(
		TARGETS
			oxfs-tool
		DESTINATION
			bin
	)
endif()

install(
	TARGETS
		OxFS
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
)

if(OX_RUN_TESTS)
	add_subdirectory(test)
endif()
