Skip to content

Commit dfa7b57

Browse files
committed
Update CMakeLists.txt
1 parent 7c1b110 commit dfa7b57

File tree

1 file changed

+40
-46
lines changed

1 file changed

+40
-46
lines changed

CMakeLists.txt

+40-46
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,44 @@ cmake_minimum_required(VERSION 3.22)
33
# Setup project
44
project(LwLibPROJECT)
55

6-
# -------------------------------------------------
7-
# This CMakeLists.txt is used only if it is a top-level file.
8-
# Purpose of it is to be able to compile project in standalone way only
9-
#
10-
# When library sources are to be included in another project
11-
# user shall use /lwmem/CMakeLists.txt instead
12-
if (NOT PROJECT_IS_TOP_LEVEL)
13-
message(FATAL_ERROR "This CMakeLists.txt can only be used as top-level. Use /lwmem/CMakeLists.txt for library include purpose")
6+
if(NOT PROJECT_IS_TOP_LEVEL)
7+
add_subdirectory(lwmem)
8+
else()
9+
# Set as executable
10+
add_executable(${PROJECT_NAME})
11+
12+
# Add key executable block
13+
target_sources(${PROJECT_NAME} PUBLIC
14+
${CMAKE_CURRENT_LIST_DIR}/dev/main.cpp
15+
${CMAKE_CURRENT_LIST_DIR}/tests/lwmem_test.c
16+
17+
# win32 port
18+
${CMAKE_CURRENT_LIST_DIR}/lwmem/src/system/lwmem_sys_win32.c
19+
)
20+
21+
# Add key include paths
22+
target_include_directories(${PROJECT_NAME} PUBLIC
23+
${CMAKE_CURRENT_LIST_DIR}
24+
${CMAKE_CURRENT_LIST_DIR}/dev
25+
)
26+
27+
# Compilation definition information
28+
target_compile_definitions(${PROJECT_NAME} PUBLIC
29+
WIN32
30+
_DEBUG
31+
CONSOLE
32+
LWMEM_DEV
33+
)
34+
35+
# Compiler options
36+
target_compile_options(${PROJECT_NAME} PRIVATE
37+
-Wall
38+
-Wextra
39+
-Wpedantic
40+
)
41+
42+
# Add subdir with lwmem and link to the project
43+
add_subdirectory(lwmem)
44+
target_link_libraries(${PROJECT_NAME} lwmem)
45+
target_link_libraries(${PROJECT_NAME} lwmem_cpp)
1446
endif()
15-
16-
# Set as executable
17-
add_executable(${PROJECT_NAME})
18-
19-
# Add key executable block
20-
target_sources(${PROJECT_NAME} PUBLIC
21-
${CMAKE_CURRENT_LIST_DIR}/dev/main.cpp
22-
${CMAKE_CURRENT_LIST_DIR}/tests/lwmem_test.c
23-
24-
# win32 port
25-
${CMAKE_CURRENT_LIST_DIR}/lwmem/src/system/lwmem_sys_win32.c
26-
)
27-
28-
# Add key include paths
29-
target_include_directories(${PROJECT_NAME} PUBLIC
30-
${CMAKE_CURRENT_LIST_DIR}
31-
${CMAKE_CURRENT_LIST_DIR}/dev
32-
)
33-
34-
# Compilation definition information
35-
target_compile_definitions(${PROJECT_NAME} PUBLIC
36-
WIN32
37-
_DEBUG
38-
CONSOLE
39-
LWMEM_DEV
40-
)
41-
42-
# Compiler options
43-
target_compile_options(${PROJECT_NAME} PRIVATE
44-
-Wall
45-
-Wextra
46-
-Wpedantic
47-
)
48-
49-
# Add subdir with lwmem and link to the project
50-
add_subdirectory("lwmem")
51-
target_link_libraries(${PROJECT_NAME} lwmem)
52-
target_link_libraries(${PROJECT_NAME} lwmem_cpp)

0 commit comments

Comments
 (0)