Skip to content

Commit

Permalink
Add higher granularity for CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Dec 27, 2021
1 parent c6fbb0f commit 078fef9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ 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")
add_subdirectory("lwow")
target_link_libraries(${PROJECT_NAME} lwow)
add_subdirectory("snippets")
Expand Down
40 changes: 33 additions & 7 deletions lwow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,29 @@ message("LWOW: Entering lib source CMakeLists.txt")
set(LWOW_LIB_NAME "lwow")

# Check definitions of some key things
if(NOT DEFINED LWOW_SYS_ARCH)
message("LWOW: LWOW_SYS_ARCH not defined. Using default one: \"win32\"")
set(LWOW_SYS_ARCH "win32")
option(LWOW_SYS_ADD_FILES OFF)
if (LWOW_SYS_ADD_FILES)
message("LWOW: LWOW_SYS_ADD_FILES is set to ON. Looking for LWOW_SYS_ARCH definition")
if(NOT DEFINED LWOW_SYS_ARCH)
message("LWOW: LWOW_SYS_ARCH not defined. Using default one: \"win32\"")
set(LWOW_SYS_ARCH "win32")
endif()
message("LWOW: LWOW_SYS_ARCH set to: " ${LWOW_SYS_ARCH})
else()
message("LWOW: LWOW_SYS_ADD_FILES is set to OFF. User must manually implement system functions in case of operating system support")
endif()
if(NOT DEFINED LWOW_LL_ARCH)
message("LWOW: LWOW_LL_ARCH not defined. Using default one: \"win32\"")
set(LWOW_LL_ARCH "win32")

# Low-level file
option(LWOW_LL_ADD_FILES OFF)
if (LWOW_LL_ADD_FILES)
message("LWOW: LWOW_LL_ADD_FILES is set to ON. Looking for LWOW_LL_ARCH definition")
if(NOT DEFINED LWOW_LL_ARCH)
message("LWOW: LWOW_LL_ARCH not defined. Using default one: \"win32\"")
set(LWOW_LL_ARCH "win32")
endif()
message("LWOW: LWOW_LL_ARCH set to: " ${LWOW_LL_ARCH})
else()
message("LWOW: LWOW_LL_ADD_FILES is set to OFF. User must manually add low-level driver file to project")
endif()

# Register library to the system
Expand All @@ -22,10 +38,20 @@ add_library(${LWOW_LIB_NAME} INTERFACE)
# Setup generic source files
target_sources(${LWOW_LIB_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/lwow/lwow.c
${CMAKE_CURRENT_LIST_DIR}/src/devices/lwow_device_ds18x20.c
)

# 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
${CMAKE_CURRENT_LIST_DIR}/src/devices/lwow_device_ds18x20.c
)
endif()

# Setup include directories
target_include_directories(${LWOW_LIB_NAME} INTERFACE
Expand Down

0 comments on commit 078fef9

Please sign in to comment.