Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
/.idea
/.vs
*.user
/debug
Expand Down
49 changes: 44 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,50 @@
# CMakeList.txt : CMake project for bcdec, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.8)
cmake_minimum_required (VERSION 3.21)

project ("bcdec" LANGUAGES C)
project (bcdec VERSION "0.97" LANGUAGES C)

# Add source to this project's executable.
add_executable (bcdec "bcdec.h" "test.c")

# TODO: Add tests and install targets if needed.
# Create library.
add_library (bcdec INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include/bcdec.h")

target_include_directories (bcdec INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)


# Create test executable.
option (BCDEC_TEST "Create the bcdec test executable" ${PROJECT_IS_TOP_LEVEL})
if (BCDEC_TEST)
add_executable (bcdec_test "${CMAKE_CURRENT_SOURCE_DIR}/test/test.c")
target_link_libraries (bcdec_test PRIVATE bcdec)
endif ()


# Add install rules.
option (BCDEC_INSTALL "Create install rules for bcdec header" ${PROJECT_IS_TOP_LEVEL})
if (BCDEC_INSTALL)
include (CMakePackageConfigHelpers)
write_basic_package_version_file (
"${PROJECT_BINARY_DIR}/bcdecConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY AnyNewerVersion
)

install (TARGETS bcdec
EXPORT bcdecTargets
PUBLIC_HEADER DESTINATION include COMPONENT Development)

include (CMakePackageConfigHelpers)
configure_package_config_file (
"${PROJECT_SOURCE_DIR}/cmake/bcdecConfig.cmake.in"
"${PROJECT_BINARY_DIR}/bcdecConfig.cmake"
INSTALL_DESTINATION lib/cmake/bcdec)

install(EXPORT bcdecTargets DESTINATION lib/cmake/bcdec)
install(FILES "${PROJECT_BINARY_DIR}/bcdecConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/bcdecConfig.cmake"
DESTINATION lib/cmake/bcdec)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)
endif ()
4 changes: 4 additions & 0 deletions cmake/bcdecConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/bcdecTargets.cmake")
check_required_components("@PROJECT_NAME@")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.