Update CMake file so it can be used with FetchContent in other projects

This commit is contained in:
Richard Knight 2021-08-01 14:06:21 +01:00
parent 92551724cf
commit 86d7dc6e43

View file

@ -2,9 +2,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(fast_obj)
SET(CMAKE_CXX_STANDARD 11)
OPTION(FAST_OBJ_BUILD_TEST "Build test application" OFF)
ADD_EXECUTABLE(test test/test.cpp)
TARGET_INCLUDE_DIRECTORIES(test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
ADD_LIBRARY(fast_obj INTERFACE)
TARGET_INCLUDE_DIRECTORIES(fast_obj INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
ADD_LIBRARY(fast_obj_lib STATIC fast_obj.c)
TARGET_INCLUDE_DIRECTORIES(fast_obj_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
IF(${FAST_OBJ_BUILD_TEST})
ADD_EXECUTABLE(fast_obj_test test/test.cpp)
TARGET_COMPILE_FEATURES(fast_obj_test PRIVATE cxx_std_11)
TARGET_LINK_LIBRARIES(fast_obj_test PRIVATE fast_obj_lib)
ENDIF()