
add_library(
	OxFS
		ptrarith/nodebuffer.hpp
		ptrarith/ptr.hpp
		filestore/filestoretemplate.cpp
		filesystem/filelocation.cpp
		filesystem/pathiterator.cpp
		filesystem/directory.cpp
		filesystem/filesystem.cpp
		filesystem/passthroughfs.cpp
)

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

if(NOT OX_BARE_METAL)
	if(NOT APPLE AND NOT MSVC AND NOT ${OX_OS_FREEBSD})
		target_link_libraries(
			OxFS PUBLIC
				stdc++fs
		)
	endif()
	set_property(
		TARGET
			OxFS
		PROPERTY
			POSITION_INDEPENDENT_CODE ON
	)
endif()

target_link_libraries(
	OxFS PUBLIC
		OxMetalClaw
)

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

	target_link_libraries(
		oxfs-tool
			OxFS
	)

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

install(
	FILES
		filestore/filestoretemplate.hpp
	DESTINATION
		include/ox/fs/filestore
)

install(
	FILES
		filesystem/filesystem.hpp
		filesystem/pathiterator.hpp
	DESTINATION
		include/ox/fs/filesystem
)

install(
	FILES
		ptrarith/nodebuffer.hpp
		ptrarith/ptr.hpp
	DESTINATION
		include/ox/fs/ptrarith
)

install(
	TARGETS
		OxFS
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
)

if(OX_RUN_TESTS)
	add_subdirectory(test)
endif()
