Skip to content

Commit

Permalink
Update cmakelists
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Dec 27, 2021
1 parent 81051de commit 50711ef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 43 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ add_executable(${PROJECT_NAME})
# Add key executable block
target_sources(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/dev/main.c

# Port files
${CMAKE_CURRENT_LIST_DIR}/lwow/src/system/lwow_sys_win32.c
${CMAKE_CURRENT_LIST_DIR}/lwow/src/system/lwow_ll_win32.c
)

# Add key include paths
Expand All @@ -36,12 +40,8 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC
)

# Add subdir with lwow and link to the project
set(LWOW_SYS_ADD_FILES ON)
set(LWOW_SYS_ARCH "win32")
set(LWOW_LL_ADD_FILES ON)
set(LWOW_LL_ARCH "win32")
set(LWOW_DEV_ADD_DS18X20 ON)
add_subdirectory("lwow")
target_link_libraries(${PROJECT_NAME} lwow)
target_link_libraries(${PROJECT_NAME} lwow_devices)
add_subdirectory("snippets")
target_link_libraries(${PROJECT_NAME} lwow_snippets)
59 changes: 21 additions & 38 deletions lwow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,32 @@
cmake_minimum_required(VERSION 3.13)

# Debug message
message("LWOW: Entering lib source CMakeLists.txt")
message("Entering ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt")

# Set library name
set(LWOW_LIB_NAME "lwow")

# Check definitions of some key things
option(LWOW_SYS_ADD_FILES "Include system architecture files coming with the library" ON)
option(LWOW_SYS_ARCH "Architecture to use for file include" "win32")
option(LWOW_LL_ADD_FILES "Include low-level driver files coming with the library" ON)
option(LWOW_LL_ARCH "Architecture to use for file include" "win32")
option(LWOW_DEV_ADD_DS18X20 "Include DS18x20 device driver to build" ON)
message("LWOW: LWOW_SYS_ADD_FILES set to: " ${LWOW_SYS_ADD_FILES})
message("LWOW: LWOW_SYS_ARCH set to: " ${LWOW_SYS_ARCH})
message("LWOW: LWOW_LL_ADD_FILES set to: " ${LWOW_LL_ADD_FILES})
message("LWOW: LWOW_LL_ARCH set to: " ${LWOW_LL_ARCH})
message("LWOW: LWOW_DEV_ADD_DS18X20 set to: " ${LWOW_DEV_ADD_DS18X20})

# Register library to the system
add_library(${LWOW_LIB_NAME} INTERFACE)

# Setup generic source files
target_sources(${LWOW_LIB_NAME} PUBLIC
# Library core sources
set(lwow_core_SRCS
${CMAKE_CURRENT_LIST_DIR}/src/lwow/lwow.c
)

# Devices
set(lwow_devices_SRCS
${CMAKE_CURRENT_LIST_DIR}/src/devices/lwow_device_ds18x20.c
)

# Setup include directories
target_include_directories(${LWOW_LIB_NAME} INTERFACE
set(lwow_include_DIRS
${CMAKE_CURRENT_LIST_DIR}/src/include
)

# Add optional sources
if (LWOW_SYS_ADD_FILES)
target_sources(${LWOW_LIB_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/system/lwow_sys_${LWOW_SYS_ARCH}.c
)
endif()
if (LWOW_LL_ADD_FILES)
target_sources(${LWOW_LIB_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/system/lwow_ll_${LWOW_LL_ARCH}.c
)
endif()
if (LWOW_DEV_ADD_DS18X20)
target_sources(${LWOW_LIB_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/devices/lwow_device_ds18x20.c
)
endif()
# Register core library to the system
add_library(lwow INTERFACE)
target_sources(lwow PUBLIC ${lwow_core_SRCS})
target_include_directories(lwow INTERFACE ${lwow_include_DIRS})

# Register API to the system
add_library(lwow_devices INTERFACE)
target_sources(lwow_devices PUBLIC ${lwow_devices_SRCS})
target_include_directories(lwow_devices INTERFACE ${lwow_include_DIRS})

# Debug message
message("Exiting ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt")

0 comments on commit 50711ef

Please sign in to comment.