-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cmake presets and build-all script
- Loading branch information
Showing
3 changed files
with
240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
# Setup project | ||
project(${PROJECT_NAME}) | ||
add_executable(${PROJECT_NAME}) | ||
message("Project name: ${PROJECT_NAME}") | ||
|
||
# Add source files | ||
target_sources(${PROJECT_NAME} PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}/main.c | ||
|
||
# Port | ||
${CMAKE_CURRENT_LIST_DIR}/../../lwesp/src/system/lwesp_sys_win32.c | ||
${CMAKE_CURRENT_LIST_DIR}/../../lwesp/src/system/lwesp_ll_win32.c | ||
|
||
# Snippets | ||
${CMAKE_CURRENT_LIST_DIR}/../../snippets/utils.c | ||
${CMAKE_CURRENT_LIST_DIR}/../../snippets/station_manager.c | ||
${CMAKE_CURRENT_LIST_DIR}/../../snippets/examples_common_lwesp_callback_func.c | ||
) | ||
|
||
# Add include paths | ||
target_include_directories(${PROJECT_NAME} PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}/ | ||
|
||
# Port | ||
${CMAKE_CURRENT_LIST_DIR}/../../lwesp/src/include/system/port/win32 | ||
|
||
# Snippets | ||
${CMAKE_CURRENT_LIST_DIR}/../../snippets/include | ||
) | ||
|
||
# Compilation definition information | ||
target_compile_definitions(${PROJECT_NAME} PUBLIC | ||
WIN32 | ||
_DEBUG | ||
CONSOLE | ||
) | ||
|
||
# Compiler options | ||
target_compile_options(${PROJECT_NAME} PRIVATE | ||
-Wall | ||
-Wextra | ||
-Wpedantic | ||
) | ||
|
||
# Add subdir with lwesp and link to the project | ||
add_subdirectory("../../lwesp" lwesp) | ||
target_link_libraries(${PROJECT_NAME} lwesp) | ||
|
||
# Project specific sources and libs | ||
if (${PROJECT_NAME} STREQUAL "client_rtos") | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/client.c) | ||
endif() | ||
if (${PROJECT_NAME} STREQUAL "dns_rtos") | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/dns.c) | ||
endif() | ||
if (${PROJECT_NAME} STREQUAL "mqtt_client_api_rtos") | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../lwesp/src/apps/mqtt/lwesp_mqtt_client.c) | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../lwesp/src/apps/mqtt/lwesp_mqtt_client_api.c) | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/mqtt_client.c) | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/mqtt_client_api.c) | ||
target_link_libraries(${PROJECT_NAME} lwesp_api) | ||
endif() | ||
if (${PROJECT_NAME} STREQUAL "mqtt_client_rtos") | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../lwesp/src/apps/mqtt/lwesp_mqtt_client.c) | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../lwesp/src/apps/mqtt/lwesp_mqtt_client_api.c) | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/mqtt_client.c) | ||
endif() | ||
if (${PROJECT_NAME} STREQUAL "netconn_client_rtos") | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/netconn_client.c) | ||
target_link_libraries(${PROJECT_NAME} lwesp_api) | ||
endif() | ||
if (${PROJECT_NAME} STREQUAL "netconn_server_rtos") | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/netconn_server.c) | ||
target_link_libraries(${PROJECT_NAME} lwesp_api) | ||
endif() | ||
if (${PROJECT_NAME} STREQUAL "sntp_rtos") | ||
target_sources(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../snippets/sntp.c) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
{ | ||
"version": 3, | ||
"configurePresets": [ | ||
{ | ||
"name": "default", | ||
"hidden": true, | ||
"generator": "Ninja", | ||
"binaryDir": "${sourceDir}/build/${presetName}", | ||
"toolchainFile": "${sourceDir}/../../cmake/i686-w64-mingw32-gcc.cmake", | ||
"cacheVariables": { | ||
"CMAKE_BUILD_TYPE": "Debug", | ||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON" | ||
} | ||
}, | ||
{ | ||
"name": "access_point_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "access_point_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "client_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "client_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "dns_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "dns_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "mqtt_client_api_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "mqtt_client_api_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "mqtt_client_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "mqtt_client_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "netconn_client_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "netconn_client_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "netconn_server_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "netconn_server_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "server_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "server_rtos" | ||
} | ||
}, | ||
{ | ||
"name": "sntp_rtos", | ||
"inherits": "default", | ||
"cacheVariables": { | ||
"PROJECT_NAME": "sntp_rtos" | ||
} | ||
} | ||
], | ||
|
||
"buildPresets": [ | ||
{ | ||
"name": "access_point_rtos", | ||
"configurePreset": "access_point_rtos" | ||
}, | ||
{ | ||
"name": "client_rtos", | ||
"configurePreset": "client_rtos" | ||
}, | ||
{ | ||
"name": "dns_rtos", | ||
"configurePreset": "dns_rtos" | ||
}, | ||
{ | ||
"name": "mqtt_client_api_rtos", | ||
"configurePreset": "mqtt_client_api_rtos" | ||
}, | ||
{ | ||
"name": "mqtt_client_rtos", | ||
"configurePreset": "mqtt_client_rtos" | ||
}, | ||
{ | ||
"name": "netconn_client_rtos", | ||
"configurePreset": "netconn_client_rtos" | ||
}, | ||
{ | ||
"name": "netconn_server_rtos", | ||
"configurePreset": "netconn_server_rtos" | ||
}, | ||
{ | ||
"name": "server_rtos", | ||
"configurePreset": "server_rtos" | ||
}, | ||
{ | ||
"name": "sntp_rtos", | ||
"configurePreset": "sntp_rtos" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
import re | ||
|
||
# Get presets from the path | ||
# Use cmake command line to list actual presets visible to cmake | ||
def get_presets(): | ||
presets = [] | ||
resp = os.popen("cmake --list-presets").read().strip() | ||
for line in resp.split("\n"): | ||
l = line.strip() | ||
r = re.findall("\"(.*)\"", l) | ||
if r: | ||
presets.append(r[0]) | ||
return presets | ||
|
||
# Main execution | ||
if __name__ == '__main__': | ||
# Get all presets | ||
failed = [] | ||
presets = get_presets() | ||
for preset in presets: | ||
print("-------------------------------") | ||
print("Configuring preset " + preset) | ||
print("-------------------------------") | ||
ret = os.system("cmake --preset " + preset) | ||
if ret != 0: | ||
print("!!!! Command failed !!!! with result code: " + str(ret)) | ||
failed.append(preset) | ||
print("Return: " + str(ret)) | ||
print("-------------------------------") | ||
print("Building preset " + preset) | ||
print("-------------------------------") | ||
ret = os.system("cmake --build --preset " + preset) | ||
if ret != 0: | ||
print("!!!! Command failed !!!! with result code: " + str(ret)) | ||
failed.append(preset) | ||
print("Return: " + str(ret)) | ||
print("-------------------------------") | ||
print("Failed presets:") | ||
for p in failed: | ||
print(p) | ||
print("-------------------------------") |