mirror of
https://github.com/meekrosoft/fff
synced 2026-01-23 00:15:59 +01:00
Add GTest with FetchContent (#120)
* Add missing GTest linking * Add unit testing switch * Rename UNIT_TESTING to be fff-specific * Add fff.h generation toggle * Use options instead of variables for disabling build elements * Add interface library for when the header is not regenerated * Update build script and README
This commit is contained in:
@@ -6,29 +6,41 @@ project(fff)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
# Add the gtest library which will be used below
|
||||
add_subdirectory(gtest)
|
||||
|
||||
# Enable ctest
|
||||
enable_testing()
|
||||
|
||||
add_library(fff INTERFACE)
|
||||
|
||||
option(FFF_GENERATE "If enabled, fff.h will be regenerated using ruby" OFF)
|
||||
|
||||
# Generate fff.h if fakegen.rb changed
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_LIST_DIR}/fff.h
|
||||
COMMAND
|
||||
ruby ${CMAKE_CURRENT_LIST_DIR}/fakegen.rb >> ${CMAKE_CURRENT_LIST_DIR}/fff.h
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_LIST_DIR}/fakegen.rb
|
||||
${CMAKE_CURRENT_LIST_DIR}/LICENSE
|
||||
)
|
||||
add_custom_target(fff_h DEPENDS ${CMAKE_CURRENT_LIST_DIR}/fff.h)
|
||||
if(FFF_GENERATE)
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_LIST_DIR}/fff.h
|
||||
COMMAND
|
||||
ruby ${CMAKE_CURRENT_LIST_DIR}/fakegen.rb >> ${CMAKE_CURRENT_LIST_DIR}/fff.h
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_LIST_DIR}/fakegen.rb
|
||||
${CMAKE_CURRENT_LIST_DIR}/LICENSE
|
||||
)
|
||||
add_custom_target(fff_h DEPENDS ${CMAKE_CURRENT_LIST_DIR}/fff.h)
|
||||
else()
|
||||
add_library(fff_h INTERFACE)
|
||||
set_target_properties(fff_h
|
||||
PROPERTIES PUBLIC_HEADER "fff.h"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_dependencies(fff fff_h)
|
||||
|
||||
# Add an interface library for fff.h
|
||||
add_library(fff INTERFACE)
|
||||
add_dependencies(fff fff_h)
|
||||
target_include_directories(fff INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# Add tests and samples
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(examples)
|
||||
option(FFF_UNIT_TESTING "If enabled, fff tests will be compiled and run" OFF)
|
||||
|
||||
if(FFF_UNIT_TESTING)
|
||||
# Add tests and samples
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user