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
VERSION 1.0.0
LANGUAGES CXX

View File

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

View File

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