diff --git a/.vscode/launch.json b/.vscode/launch.json index 214334d..8b95413 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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, diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 26e109d..309d100 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -46,7 +46,7 @@ { "type": "shell", "label": "Run application", - "command": "${workspaceFolder}\\build\\LwMEM.exe", + "command": "${workspaceFolder}\\build\\LwLibPROJECT.exe", "args": [], "problemMatcher": [], }, diff --git a/CMakeLists.txt b/CMakeLists.txt index 3655abf..287367b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() \ No newline at end of file +# 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) \ No newline at end of file