Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
option(FFF_BUILD_TESTS "Whether or not to build the tests" ON)
option(FFF_BUILD_EXAMPLES "Whether or not to build the examples" ON)
option(FFF_GENERATE "Whether or not to generate fff.h" ON)

project(fff)

set(CMAKE_CXX_STANDARD 11)

# Add the gtest library which will be used below
add_subdirectory(gtest)

# Enable ctest
enable_testing()

if(FFF_GENERATE)
# 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_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
)
endif()
add_custom_target(fff_h DEPENDS ${CMAKE_CURRENT_LIST_DIR}/fff.h)

# Add an interface library for fff.h
Expand All @@ -30,5 +30,16 @@ add_dependencies(fff fff_h)
target_include_directories(fff INTERFACE ${CMAKE_CURRENT_LIST_DIR})

# Add tests and samples
add_subdirectory(test)
add_subdirectory(examples)
if(FFF_BUILD_TESTS)
# Add the gtest library which will be used below
add_subdirectory(gtest)

# Enable ctest
enable_testing()

add_subdirectory(test)
endif()

if(FFF_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()