From 7adac00035b8f345dab09294c6d4080c8b53c33a Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 3 Nov 2024 17:29:34 +0800 Subject: [PATCH] doc: fix document about recent changes - fix build commandline introduction in documentation. - update build script template. - only install document in any Release-like build type. - now testbench will be installed in any Release-like build type, not only Release. --- doc/CMakeLists.txt | 1 + doc/src/intro.dox | 7 ++++-- doc/src/library_macros.dox | 42 ++++++++++++++++++++++++++++++++++ script/linux_build.template.sh | 4 ++-- script/win_build.template.bat | 18 +++++++-------- src/YYCC/YYCCInternal.hpp | 2 +- testbench/CMakeLists.txt | 2 +- 7 files changed, 61 insertions(+), 15 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 3804460..12a10e2 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -14,5 +14,6 @@ add_custom_target (YYCCDocumentation # Install built documentation install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html + CONFIGURATIONS Release RelWithDebInfo MinSizeRel DESTINATION ${YYCC_INSTALL_DOC_PATH} ) diff --git a/doc/src/intro.dox b/doc/src/intro.dox index f8db8cb..e915fd2 100644 --- a/doc/src/intro.dox +++ b/doc/src/intro.dox @@ -116,11 +116,14 @@ Due to the different defination of UTF8 char type, C++ 20 program can not use this library built by C++ 17 environment. So this switch give you a chance to decide the version of C++ standard used when building. The lowest and defult version of C++ standard is 17. -\li \c -d, \c --no-doc: Specify this if you don't want to build documentation. +\li \c -d, \c --build-doc: Specify this if you want to build documentation. End user usually needs documentation, however if you are the developer of this library, you may need this switch. Because documentation take too much disk space and cost a bunch of time for building and copying. -In default, generator will produce script which build documentation automatically. +In default, generator will produce script which do not build documentation automatically. +\li \c -p, \c --pic: Enable Position Independent Code flag on non-Windows platfotm. +This flag is crucial to linking this library to another dynamic library. +If you do not specify this flag, the linking process will fail. After script done, you will find CMake distribution in directory bin/cpp_ver/install. and you will also find your MSVC distribution in directory bin/cpp_ver/msvc_install. diff --git a/doc/src/library_macros.dox b/doc/src/library_macros.dox index e4bdee8..f490e99 100644 --- a/doc/src/library_macros.dox +++ b/doc/src/library_macros.dox @@ -6,6 +6,48 @@ namespace YYCC { In this page we will introduce the macros defined by this library which can not be grouped in other topic. +\section library_macros__batch_class_copy_move Library Version and Version Comparison + +Version is a important things in modern software development, especially for a library. +In YYCC, we use Semantic Versioning as our version standard. +For more infomations about it, please see: https://semver.org/ + +First, YYCC has its own version and it can be visited by +\c YYCC_VER_MAJOR, \c YYCC_VER_MINOR, and \c YYCC_VER_PATCH. +Each part of Semantic Versioning is provided individually. + +YYCC also provide a bunch of macros to compare 2 versions. +It also provides a way to check YYCC version in program using YYCC, +because some of them rely on a specific version of YYCC. +There is a list of these comparison macros. + +\li YYCC_VERCMP_E +\li YYCC_VERCMP_NE +\li YYCC_VERCMP_G +\li YYCC_VERCMP_GE +\li YYCC_VERCMP_NL +\li YYCC_VERCMP_L +\li YYCC_VERCMP_LE +\li YYCC_VERCMP_NG + +You may notice all of these macros are starts with \c YYCC_VERCMP_, +and their tails are inspired from x86 ASM comparison jump code. +For example, \c E means "equal" and \c NE means "not equal", +\c G means "greater", \c GE means "greater or equal", and \c NG means "not gretaer". + +All of these macros take 6 arguments, +for the first 3 arguments, we call them "left version". +From left to right they are the major part, minor part and patch part of semantic version. +And for the last 3 arguments, we call them "right version". +From left to right they are the major part, minor part and patch part of semantic version. +There is a example about checking whether YYCC library version is exactly what we wanted version. + +\code +#if YYCC_VERCMP_NE(YYCC_VER_MAJOR, YYCC_VER_MINOR, YYCC_VER_PATCH, 1, 3 ,0) +#error "Not Matched YYCC Version" +#endif +\endcode + \section library_macros__platform_checker Platform Checker In many cross platform applications, diff --git a/script/linux_build.template.sh b/script/linux_build.template.sh index 0c23c74..7bafee3 100644 --- a/script/linux_build.template.sh +++ b/script/linux_build.template.sh @@ -16,10 +16,10 @@ cd .. # Build current system debug and release version cd build -cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD={{ cpp_version }} {{ '-DCMAKE_POSITION_INDEPENDENT_CODE=True' if pic else '' }} ../.. --fresh +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD={{ cpp_version }} {{ '-DCMAKE_POSITION_INDEPENDENT_CODE=True' if pic }} ../.. --fresh cmake --build . cmake --install . --prefix ../install/Debug -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD={{ cpp_version }} {{ '-DCMAKE_POSITION_INDEPENDENT_CODE=True' if pic else '' }} -DYYCC_BUILD_TESTBENCH=ON ../.. --fresh +cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_STANDARD={{ cpp_version }} {{ '-DCMAKE_POSITION_INDEPENDENT_CODE=True' if pic }} -DYYCC_BUILD_TESTBENCH=ON ../.. --fresh cmake --build . cmake --install . --prefix ../install/Release cd .. diff --git a/script/win_build.template.bat b/script/win_build.template.bat index 9e207af..f8214e1 100644 --- a/script/win_build.template.bat +++ b/script/win_build.template.bat @@ -40,28 +40,28 @@ CD .. :: Build for Win32 CD Win32 -cmake -G "Visual Studio 16 2019" -A Win32 -DCMAKE_CXX_STANDARD={{ cpp_version }} -DYYCC_BUILD_TESTBENCH=ON ../../.. +cmake -A Win32 -DCMAKE_CXX_STANDARD={{ cpp_version }} -DYYCC_BUILD_TESTBENCH=ON ../../.. cmake --build . --config Debug cmake --install . --prefix=../install/Win32_Debug --config Debug -cmake --build . --config Release -cmake --install . --prefix=../install/Win32_Release --config Release +cmake --build . --config RelWithDebInfo +cmake --install . --prefix=../install/Win32_Release --config RelWithDebInfo CD .. :: Build for x64 CD x64 -cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_CXX_STANDARD={{ cpp_version }} -DYYCC_BUILD_TESTBENCH=ON ../../.. +cmake -A x64 -DCMAKE_CXX_STANDARD={{ cpp_version }} -DYYCC_BUILD_TESTBENCH=ON ../../.. cmake --build . --config Debug cmake --install . --prefix=../install/x64_Debug --config Debug -cmake --build . --config Release -cmake --install . --prefix=../install/x64_Release --config Release +cmake --build . --config RelWithDebInfo +cmake --install . --prefix=../install/x64_Release --config RelWithDebInfo CD .. {% if build_doc %} :: Build for documentation CD documentation -'cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_CXX_STANDARD={{ cpp_version }} -DYYCC_BUILD_DOC=ON ../../.. -cmake --build . --config Release +cmake -A x64 -DCMAKE_CXX_STANDARD={{ cpp_version }} -DYYCC_BUILD_DOC=ON ../../.. +cmake --build . --config RelWithDebInfo cmake --build . --target YYCCDocumentation -cmake --install . --prefix=../install/x64_Release --config Release +cmake --install . --prefix=../install/x64_Release --config RelWithDebInfo CD .. {% endif %} diff --git a/src/YYCC/YYCCInternal.hpp b/src/YYCC/YYCCInternal.hpp index 3aaac7b..ba6f080 100644 --- a/src/YYCC/YYCCInternal.hpp +++ b/src/YYCC/YYCCInternal.hpp @@ -1,6 +1,6 @@ #pragma once -#pragma region Library Version and Comparation Macros +#pragma region Library Version and Comparison Macros #define YYCC_VER_MAJOR 1 #define YYCC_VER_MINOR 3 diff --git a/testbench/CMakeLists.txt b/testbench/CMakeLists.txt index 68805f4..0a19192 100644 --- a/testbench/CMakeLists.txt +++ b/testbench/CMakeLists.txt @@ -31,6 +31,6 @@ PRIVATE # Install testbench only on Release mode install(TARGETS YYCCTestbench - CONFIGURATIONS Release + CONFIGURATIONS Release RelWithDebInfo MinSizeRel RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH} )