chore: update CMakeLists

- update the use of target_sources() to remove duplicated header file declarations.
	- thx Gary Wang
This commit is contained in:
yyc12345 2024-06-15 21:53:45 +08:00
parent 5481898ad9
commit 8465d80a54
3 changed files with 32 additions and 47 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.23)
project(YYCC project(YYCC
VERSION 1.0.0 VERSION 1.0.0
LANGUAGES CXX LANGUAGES CXX

View File

@ -3,35 +3,40 @@ add_library(YYCCommonplace STATIC "")
# Setup static library sources # Setup static library sources
target_sources(YYCCommonplace target_sources(YYCCommonplace
PRIVATE PRIVATE
# Sources
ConsoleHelper.cpp
DialogHelper.cpp
EncodingHelper.cpp
ExceptionHelper.cpp
FsPathPatch.cpp
IOHelper.cpp
ParserHelper.cpp
StringHelper.cpp
WinFctHelper.cpp
)
target_sources(YYCCommonplace
PUBLIC
FILE_SET HEADERS
FILES
# Headers # Headers
# Common headers # Common headers
${CMAKE_CURRENT_LIST_DIR}/ConsoleHelper.hpp ConsoleHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/DialogHelper.hpp DialogHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/EncodingHelper.hpp EncodingHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/ExceptionHelper.hpp ExceptionHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/FsPathPatch.hpp FsPathPatch.hpp
${CMAKE_CURRENT_LIST_DIR}/IOHelper.hpp IOHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/ParserHelper.hpp ParserHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/StringHelper.hpp StringHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/WinFctHelper.hpp WinFctHelper.hpp
# Windows including guard pair # Windows including guard pair
${CMAKE_CURRENT_LIST_DIR}/WinImportPrefix.hpp WinImportPrefix.hpp
${CMAKE_CURRENT_LIST_DIR}/WinImportSuffix.hpp WinImportSuffix.hpp
# Misc # Misc
${CMAKE_CURRENT_LIST_DIR}/YYCCInternal.hpp YYCCInternal.hpp
${CMAKE_CURRENT_LIST_DIR}/YYCCommonplace.hpp YYCCommonplace.hpp
# Sources
${CMAKE_CURRENT_LIST_DIR}/ConsoleHelper.cpp
${CMAKE_CURRENT_LIST_DIR}/DialogHelper.cpp
${CMAKE_CURRENT_LIST_DIR}/EncodingHelper.cpp
${CMAKE_CURRENT_LIST_DIR}/ExceptionHelper.cpp
${CMAKE_CURRENT_LIST_DIR}/FsPathPatch.cpp
${CMAKE_CURRENT_LIST_DIR}/IOHelper.cpp
${CMAKE_CURRENT_LIST_DIR}/ParserHelper.cpp
${CMAKE_CURRENT_LIST_DIR}/StringHelper.cpp
${CMAKE_CURRENT_LIST_DIR}/WinFctHelper.cpp
) )
# Setup header infomations # Setup header infomations
target_include_directories(YYCCommonplace target_include_directories(YYCCommonplace
PUBLIC PUBLIC
@ -65,25 +70,5 @@ install(TARGETS YYCCommonplace
ARCHIVE DESTINATION lib ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
INCLUDES DESTINATION include INCLUDES DESTINATION include
) FILE_SET HEADERS DESTINATION include
# Install headers
install(
FILES
# Common headers
${CMAKE_CURRENT_LIST_DIR}/ConsoleHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/DialogHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/EncodingHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/ExceptionHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/FsPathPatch.hpp
${CMAKE_CURRENT_LIST_DIR}/IOHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/ParserHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/StringHelper.hpp
${CMAKE_CURRENT_LIST_DIR}/WinFctHelper.hpp
# Windows including guard pair
${CMAKE_CURRENT_LIST_DIR}/WinImportPrefix.hpp
${CMAKE_CURRENT_LIST_DIR}/WinImportSuffix.hpp
# Misc
${CMAKE_CURRENT_LIST_DIR}/YYCCInternal.hpp
${CMAKE_CURRENT_LIST_DIR}/YYCCommonplace.hpp
DESTINATION include
) )

View File

@ -3,7 +3,7 @@ add_executable(YYCCTestbench "")
# Setup testbench sources # Setup testbench sources
target_sources(YYCCTestbench target_sources(YYCCTestbench
PRIVATE PRIVATE
${CMAKE_CURRENT_LIST_DIR}/main.cpp main.cpp
) )
# Add YYCC as its library # Add YYCC as its library
target_include_directories(YYCCTestbench target_include_directories(YYCCTestbench