Skip to content

Commit

Permalink
Update CMakeLists.txt for each library and split core and optional mo…
Browse files Browse the repository at this point in the history
…dules
  • Loading branch information
MaJerle committed Dec 27, 2021
1 parent 078fef9 commit 81051de
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Win32",
"includePath": [
"${workspaceFolder}\\dev\\VisualStudio\\",
"${workspaceFolder}\\dev\\",
"${workspaceFolder}\\lwow\\src\\include\\"
],
"defines": [
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"files.associations": {
"lwow.h": "c",
"lwow_sys.h": "c"
}
}
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ 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)
add_subdirectory("snippets")
Expand Down
62 changes: 26 additions & 36 deletions lwow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,43 @@ message("LWOW: Entering lib source CMakeLists.txt")
set(LWOW_LIB_NAME "lwow")

# Check definitions of some key things
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()

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

# Setup include directories
target_include_directories(${LWOW_LIB_NAME} INTERFACE
${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
)
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
)
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()

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

0 comments on commit 81051de

Please sign in to comment.