Skip to content

Commit

Permalink
Create .cmake file to allow higher flexibility of end user
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Dec 9, 2023
1 parent 4ab454b commit 9ba9f99
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
10 changes: 1 addition & 9 deletions lwbtn/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
cmake_minimum_required(VERSION 3.22)

# Register library to the system
add_library(lwbtn INTERFACE)
target_sources(lwbtn INTERFACE ${CMAKE_CURRENT_LIST_DIR}/src/lwbtn/lwbtn.c)
target_include_directories(lwbtn INTERFACE ${CMAKE_CURRENT_LIST_DIR}/src/include)

# Create config file
if(DEFINED LWBTN_OPTS_DIR AND NOT EXISTS ${LWBTN_OPTS_DIR}/lwbtn_opts.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/src/include/lwbtn/lwbtn_opts_template.h ${LWBTN_OPTS_DIR}/lwbtn_opts.h COPYONLY)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/library.cmake)
21 changes: 21 additions & 0 deletions lwbtn/library.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Library core sources
set(lwbtn_core_SRCS
${CMAKE_CURRENT_LIST_DIR}/src/lwbtn/lwbtn.c
)

# Setup include directories
set(lwbtn_include_DIRS
${CMAKE_CURRENT_LIST_DIR}/src/include
)

# Register library to the system
add_library(lwbtn INTERFACE)
target_sources(lwbtn INTERFACE ${lwbtn_core_SRCS})
target_include_directories(lwbtn INTERFACE ${lwbtn_include_DIRS})
target_compile_options(lwbtn PRIVATE ${LWBTN_COMPILE_OPTIONS})
target_compile_definitions(lwbtn PRIVATE ${LWBTN_COMPILE_DEFINITIONS})

# Create config file
if(DEFINED LWBTN_OPTS_DIR AND NOT EXISTS ${LWBTN_OPTS_DIR}/lwbtn_opts.h)
configure_file(${CMAKE_CURRENT_LIST_DIR}/src/include/lwbtn/lwbtn_opts_template.h ${LWBTN_OPTS_DIR}/lwbtn_opts.h COPYONLY)
endif()

0 comments on commit 9ba9f99

Please sign in to comment.