Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fff installable #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
43 changes: 31 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,57 @@ set(CMAKE_CXX_STANDARD 11)
# 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
if(FFF_GENERATE)
find_package(Ruby REQUIRED)

add_custom_command(
OUTPUT
${CMAKE_CURRENT_LIST_DIR}/fff.h
${CMAKE_BINARY_DIR}/fff.h
COMMAND
ruby ${CMAKE_CURRENT_LIST_DIR}/fakegen.rb >> ${CMAKE_CURRENT_LIST_DIR}/fff.h
${Ruby_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/fakegen.rb >> ${CMAKE_BINARY_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)
add_library(fff INTERFACE ${CMAKE_BINARY_DIR}/fff.h)
target_include_directories(fff INTERFACE
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
set_target_properties(fff
PROPERTIES PUBLIC_HEADER "${CMAKE_BINARY_DIR}/fff.h"
)
else()
add_library(fff_h INTERFACE)
set_target_properties(fff_h
add_library(fff INTERFACE)
target_include_directories(fff INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
set_target_properties(fff
PROPERTIES PUBLIC_HEADER "fff.h"
)
endif()

add_dependencies(fff fff_h)

# Add an interface library for fff.h
target_include_directories(fff INTERFACE ${CMAKE_CURRENT_LIST_DIR})

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()

include(GNUInstallDirs)

install(TARGETS fff EXPORT fffTargets
PUBLIC_HEADER
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT fffTargets
FILE fffTargets.cmake
NAMESPACE fff::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/fff)
install(FILES fffConfig.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/fff)
1 change: 1 addition & 0 deletions fffConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/fffTargets.cmake")
Loading