summary history branches tags files
examples/CMakeLists.txt
cmake_minimum_required(VERSION 3.12)
project(ffi C)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto -O3")
option(LINK_STATIC "Link against static library" false)

if (APPLE)
set(DYNEXT "dylib")
else()
set(DYNEXT "so")
endif()


add_executable (ffi ffi.c)
target_include_directories (ffi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ffi)
if (LINK_STATIC)
	target_link_libraries (ffi LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.a)
	find_library(SECURITY_FRAMEWORK Security)
	target_link_libraries(ffi LINK_PUBLIC ${SECURITY_FRAMEWORK})
else()
	target_link_libraries (ffi LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.${DYNEXT})
endif()

add_executable (client client.c)
add_executable (server server.c)
target_include_directories (client PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ffi)
target_include_directories (server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../ffi)

if (LINK_STATIC)
	target_link_libraries (client LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.a)
	target_link_libraries (server LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.a)
	#target_link_libraries (server LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/x86_64-apple-darwin/release/libossuary.a)
	find_library(SECURITY_FRAMEWORK Security)
	target_link_libraries(client LINK_PUBLIC ${SECURITY_FRAMEWORK})
	target_link_libraries(server LINK_PUBLIC ${SECURITY_FRAMEWORK})
else()
	target_link_libraries (client LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.${DYNEXT})
	target_link_libraries (server LINK_PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../target/release/libossuary.${DYNEXT})
endif()