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
19 changes: 16 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,20 @@ cmake_minimum_required (VERSION 3.8)

project ("bcdec" LANGUAGES C)

# Add source to this project's executable.
add_executable (bcdec "bcdec.h" "test.c")
option(BCDEC_BUILD_TESTS "Build test executable" OFF)
option(BCDEC_STATIC_LIB "Build as static library instead of interface library" OFF)

# TODO: Add tests and install targets if needed.
if(BCDEC_STATIC_LIB)
# Static library - compiled implementation
add_library(bcdec STATIC bcdec.h bcdec.c)
target_include_directories(bcdec PUBLIC ${CMAKE_CURRENT_LIST_DIR})
else()
# Interface library - header-only, requires BCDEC_IMPLEMENTATION definition
add_library(bcdec INTERFACE bcdec.h)
target_include_directories(bcdec INTERFACE ${CMAKE_CURRENT_LIST_DIR})
endif()

# Optionally build test executable
if(BCDEC_BUILD_TESTS)
add_executable(bcdec_test "bcdec.h" "test.c")
endif()
2 changes: 2 additions & 0 deletions bcdec.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define BCDEC_IMPLEMENTATION
#include "bcdec.h"