mirror of
https://github.com/MaJerle/lwbtn.git
synced 2026-02-06 12:43:10 +08:00
Improve the CMakeLists library usage
This commit is contained in:
@@ -6,39 +6,23 @@ project(LwLibPROJECT)
|
||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
||||
add_subdirectory(lwbtn)
|
||||
else()
|
||||
# Set as executable
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
# Add key executable block
|
||||
target_sources(${PROJECT_NAME} PUBLIC
|
||||
target_sources(${PROJECT_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/dev/main.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/examples/example_win32.c
|
||||
${CMAKE_CURRENT_LIST_DIR}/examples/test.c
|
||||
)
|
||||
|
||||
# Add key include paths
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_LIST_DIR}/dev
|
||||
${CMAKE_CURRENT_LIST_DIR}/examples
|
||||
)
|
||||
|
||||
# Compilation definition information
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC
|
||||
WIN32
|
||||
_DEBUG
|
||||
CONSOLE
|
||||
LWBTN_DEV
|
||||
)
|
||||
|
||||
# Compiler options
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
)
|
||||
|
||||
# Add subdir with lwbtn and link to project
|
||||
set(LWBTN_OPTS_FILE ${CMAKE_CURRENT_LIST_DIR}/dev/lwbtn_opts.h)
|
||||
add_subdirectory(lwbtn)
|
||||
target_link_libraries(${PROJECT_NAME} lwbtn)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC lwbtn)
|
||||
|
||||
# Add compile options to the library, which will propagate options to executable through public link
|
||||
target_compile_definitions(lwbtn PUBLIC WIN32 _DEBUG CONSOLE LWBTN_DEV)
|
||||
target_compile_options(lwbtn PRIVATE -Wall -Wextra -Wpedantic)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user