-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CMakeLists.txt for library or project
- Loading branch information
Showing
2 changed files
with
55 additions
and
14 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 |
---|---|---|
@@ -1,26 +1,40 @@ | ||
cmake_minimum_required(VERSION 3.0.0) | ||
project(LwLibPROJECT VERSION 0.1.0) | ||
|
||
include(CTest) | ||
enable_testing() | ||
# Setup project | ||
project(LwLibPROJECT VERSION 2.0.1) | ||
|
||
add_executable(${PROJECT_NAME} | ||
lwprintf/src/lwprintf/lwprintf.c | ||
lwprintf/src/system/lwprintf_sys_win32.c | ||
dev/VisualStudio/main.c | ||
# ------------------------------------------------- | ||
# 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() | ||
|
||
# Set as executable | ||
add_executable(${PROJECT_NAME}) | ||
|
||
# Add key executable block | ||
target_sources(${PROJECT_NAME} PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio/main.c | ||
) | ||
|
||
target_include_directories(${PROJECT_NAME} PRIVATE | ||
dev/VisualStudio | ||
lwprintf/src/include | ||
# Add key include paths | ||
target_include_directories(${PROJECT_NAME} PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR} | ||
${CMAKE_CURRENT_LIST_DIR}/dev/VisualStudio | ||
) | ||
|
||
target_compile_definitions(${PROJECT_NAME} PRIVATE | ||
# Compilation definition information | ||
target_compile_definitions(${PROJECT_NAME} PUBLIC | ||
WIN32 | ||
_DEBUG | ||
CONSOLE | ||
LWMEM_DEV | ||
) | ||
|
||
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | ||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) | ||
include(CPack) | ||
# Add subdir with lwmem and link to the project | ||
add_subdirectory("lwprintf") | ||
target_link_libraries(${PROJECT_NAME} lwprintf) |
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,27 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
|
||
# Debug message | ||
message("LWPRINTF: Entering lib source CMakeLists.txt") | ||
|
||
# Set library name | ||
set(LWPRINTF_LIB_NAME "lwprintf") | ||
|
||
# Check definitions of some key things | ||
if(NOT DEFINED LWMEM_SYS_ARCH) | ||
message("LWPRINTF: LWPRINTF_SYS_ARCH not defined. Using default one: \"win32\"") | ||
set(LWMEM_SYS_ARCH "win32") | ||
endif() | ||
|
||
# Register library to the system | ||
add_library(${LWPRINTF_LIB_NAME} INTERFACE) | ||
|
||
# Setup generic source files | ||
target_sources(${LWPRINTF_LIB_NAME} PUBLIC | ||
${CMAKE_CURRENT_LIST_DIR}/src/lwprintf/lwprintf.c | ||
${CMAKE_CURRENT_LIST_DIR}/src/system/lwprintf_sys_${LWMEM_SYS_ARCH}.c | ||
) | ||
|
||
# Setup include directories | ||
target_include_directories(${LWPRINTF_LIB_NAME} INTERFACE | ||
${CMAKE_CURRENT_LIST_DIR}/src/include | ||
) |