Update cmake

This commit is contained in:
Tilen Majerle 2021-12-24 15:19:24 +01:00
parent d9f91da6df
commit 54c9c1c07c
3 changed files with 35 additions and 29 deletions

2
.vscode/launch.json vendored
View File

@ -8,7 +8,7 @@
"name": "(Windows) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}\\build\\LwMEM.exe",
"program": "${workspaceFolder}\\build\\LwLibPROJECT.exe",
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
"args": [],
"stopAtEntry": false,

2
.vscode/tasks.json vendored
View File

@ -46,7 +46,7 @@
{
"type": "shell",
"label": "Run application",
"command": "${workspaceFolder}\\build\\LwMEM.exe",
"command": "${workspaceFolder}\\build\\LwLibPROJECT.exe",
"args": [],
"problemMatcher": [],
},

View File

@ -1,35 +1,41 @@
cmake_minimum_required(VERSION 3.0.0)
# Setup project
project(LwMEM VERSION 2.0.1)
project(LwLibPROJECT VERSION 2.0.1)
# ------------------------
# Configuration used if cmake uses this as
# top-level project CMakeLists.txt file
# This is normally used for development purpose only
if (PROJECT_IS_TOP_LEVEL)
add_executable(${PROJECT_NAME})
# -------------------------------------------------
# This CMakeLists.txt is used only if it is a top-level file.
# Purpose of it is to be able to compile project in standalone way only
#
# When library sources are to be included in another project
# user shall use /lwmem/CMakeLists.txt instead
if (NOT PROJECT_IS_TOP_LEVEL)
message(FATAL_ERROR "This CMakeLists.txt can only be used as top-level. Use /lwmem/CMakeLists.txt for library include purpose")
endif()
# Add key executable block
target_sources(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio/main.c
${CMAKE_CURRENT_LIST_DIR}/tests/lwmem_test.c
)
# Set as executable
add_executable(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio
)
# Add key executable block
target_sources(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio/main.c
${CMAKE_CURRENT_LIST_DIR}/tests/lwmem_test.c
)
target_compile_definitions(${PROJECT_NAME} PUBLIC
WIN32
_DEBUG
CONSOLE
LWMEM_DEV
)
# Add key include paths
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio
)
# Add subdir with lwmem and link to the project
add_subdirectory("lwmem")
target_link_libraries(${PROJECT_NAME} lwmem)
else()
message("LWMEM: For library link, use CMakeLists.txt in /lwmem directory")
endif()
# Compilation definition information
target_compile_definitions(${PROJECT_NAME} PUBLIC
WIN32
_DEBUG
CONSOLE
LWMEM_DEV
)
# Add subdir with lwmem and link to the project
add_subdirectory("lwmem")
target_link_libraries(${PROJECT_NAME} lwmem)