From c3dd7fc54c53b038453bcf59371ec89f239597d0 Mon Sep 17 00:00:00 2001 From: Simplxs Date: Wed, 29 Nov 2023 20:21:13 +0800 Subject: [PATCH] add some discriptions of mdflibrary --- CMakeLists.txt | 17 +++++++++-------- CMakePresets.json | 24 ++---------------------- README.md | 29 +++++++++++++++-------------- mdflib/CMakeLists.txt | 6 +++--- mdflibrary/CMakeLists.txt | 16 +++++++++++++--- mdflibrary_example/CMakeLists.txt | 4 +++- mdfviewer/CMakeLists.txt | 11 ++++------- 7 files changed, 49 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f345fcd6..85ab98fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,18 +9,19 @@ else() endif() option(MDF_BUILD_SHARED_LIB "Build shared library." ON) +option(MDF_BUILD_SHARED_LIB_NET "Build shared library with .NET." ON) option(MDF_BUILD_SHARED_LIB_EXAMPLE "Build MdfLibrary Example." OFF) option(MDF_BUILD_DOC "Build documentation. Requires Doxygen and Release mode." OFF) option(MDF_BUILD_TOOL "Build tools like the MDF Viewer. Requires WxWidgets." OFF) if(MDF_BUILD_TOOL AND VCPKG) - # Boost & wxWidgets is not available for static linking - string(REPLACE "-static" "" VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}") +# Boost & wxWidgets need /MT for static linking + string(REPLACE VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}") list(APPEND VCPKG_MANIFEST_FEATURES "mdfviewer") endif() option(MDF_BUILD_TEST "Build Google unit tests. Requires Google Test." OFF) if(MDF_BUILD_TEST AND VCPKG) - # GTest is not available for static linking - string(REPLACE "-static" "" VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}") +# GTest need /MT for static linking + string(REPLACE VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}") list(APPEND VCPKG_MANIFEST_FEATURES "mdflibtest") endif() @@ -29,13 +30,13 @@ project( VERSION 2.0 DESCRIPTION "Interface against MDF 3/4 files" LANGUAGES CXX) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_DEBUG_POSTFIX d) - + add_subdirectory(mdflib) if(MDF_BUILD_SHARED_LIB) + if(NOT (MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.36)) + set(MDF_BUILD_SHARED_LIB_NET OFF) + endif() add_subdirectory(mdflibrary) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 8fe3c044..3b572821 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -39,7 +39,7 @@ "VCPKG_TARGET_TRIPLET": "x86-windows-static", "CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}" } - } + } ], "buildPresets": [ { @@ -98,26 +98,6 @@ "ALL_BUILD", "install" ] - } - ], - "testPresets": [ - { - "name": "ninja-multi-vcpkg-x64", - "description": "Build ninja-multi-vcpkg-x64 GTest", - "displayName": "Build ninja-multi-vcpkg-x64 GTest", - "configurePreset": "ninja-multi-vcpkg-x64" - }, - { - "name": "msvc-multi-vcpkg-x64", - "description": "Build msvc-multi-vcpkg-x64 GTest", - "displayName": "Build msvc-multi-vcpkg-x64 GTest", - "configurePreset": "msvc-multi-vcpkg-x64" - }, - { - "name": "msvc-multi-vcpkg-x64_x86", - "description": "Build msvc-multi-vcpkg-x64_x86 GTest", - "displayName": "Build msvc-multi-vcpkg-x64_x86 GTest", - "configurePreset": "msvc-multi-vcpkg-x64_x86" - } + } ] } \ No newline at end of file diff --git a/README.md b/README.md index 70050f10..32aaba0d 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,16 @@ The MDF library repository implements an interface against the ASAM Measurement It supports reading and writing of MDF files version 3 and 4. The release 2.0 of the project support reading and writing of MDF files up to version 4.2. -The main project is a C++ static library and its used applications. -- **MDF Viewer**. Simple GUI application that list the contents of an MDF file. -- **MDF .NET (C++/CLI) Assembly**. Basic reading of MDF files for .NET friends. +- **MDF lib** is a C++ static library. +- **MDF lib test** is a C++ unit tests application for mdflib. +- **MDF library** is a C++ shared library, and it contains .NET (C++/CLI) Assembly(need to be built with msvc>=19.36). +- **MDF library example** is a C++ application that use MDF library as dll/so. +- **MDF library test net** is a C# unit tests application that use the .NET Assembly of MDF library. +- **MDF Viewer**. Simple GUI application that list the contents of an MDF file. - **MDF gRPC Server**. Microservice for reading and writing of MDF files. On request. - **MDF Python Library**. Basic reading and writing for Python friends. On request or use the ASAMMDF library. -The library and its applications, compiles/runs on Windows, Linux and Mac operating system. -The .NET library only runs on Windows operating system. +The library and its applications, compiles/runs on Windows, Linux and Mac operating system. ## Installation @@ -21,19 +23,18 @@ The .NET library only runs on Windows operating system. ## Building -Most project uses CMAKE for building. But mdflibrary_test_net need to build with Visual Studio. +The project uses CMAKE for building. But mdflibrary_test_net is a Visual Studio build. -The following third-party libraries are improted by [vcpkg](https://github.com/microsoft/vcpkg). -- ZLIB Library. -- EXPAT Library. -- Boost Library. Required if the GUI applications should be built. -- WxWidgets Library. Required if the GUI applications should be built. -- Google Test Library. Is required for running and build the unit tests. +The following third-party libraries are used and needs to be downloaded and pre-built. -The following third-party application need to be downloaded by yourself. +- ZLIB Library. Set the 'ZLIB_ROOT' variable to the ZLIB root path. +- EXPAT Library. Set the 'EXPAT_ROOT' variable to the ZLIB root path. +- Boost Library. Required if the GUI applications should be built. +- WxWidgets Library. Required if the GUI applications should be built. +- Google Test Library. Is required for running and build the unit tests. - Doxygen's application. Is required if the documentation should be built. - +Also, you can use [vcpkg](https://github.com/microsoft/vcpkg) to import the dependencies. ## License diff --git a/mdflib/CMakeLists.txt b/mdflib/CMakeLists.txt index 3f2f9505..5ac014f2 100644 --- a/mdflib/CMakeLists.txt +++ b/mdflib/CMakeLists.txt @@ -1,6 +1,9 @@ # Copyright 2023 Simplxs # SPDX-License-Identifier: MIT +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_DEBUG_POSTFIX d) + add_library(mdf STATIC src/mdfblock.cpp src/mdfblock.h src/mdffile.cpp ../include/mdf/mdffile.h @@ -107,9 +110,6 @@ endif() target_include_directories( mdf PUBLIC $) -# set_target_properties(mdflib PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS -# "-m32") - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set_target_properties(mdf PROPERTIES COMPILE_FLAGS "-fPIC") endif() diff --git a/mdflibrary/CMakeLists.txt b/mdflibrary/CMakeLists.txt index 0564144c..df3da8d0 100644 --- a/mdflibrary/CMakeLists.txt +++ b/mdflibrary/CMakeLists.txt @@ -1,12 +1,23 @@ # Copyright 2023 Simplxs # SPDX-License-Identifier: MIT +project( + mdflibrary + VERSION 2.0 + DESCRIPTION "Interface against MDF 3/4 files" + LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_DEBUG_POSTFIX d) + message(STATUS "Compiler Version " ${CMAKE_CXX_COMPILER_VERSION}) message(STATUS "MSVC " ${MSVC}) -if (MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.36) +if (MDF_BUILD_SHARED_LIB_NET) message(STATUS "CLR compile") - # Hander files for building c# clr add_library(mdflibrary SHARED + # C++ files src/MdfExport.cpp + + # Following files are needed for clr src/AssemblyInfo.cpp src/MdfAttachment.cpp src/MdfAttachment.h src/MdfChannel.cpp src/MdfChannel.h @@ -27,7 +38,6 @@ if (MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.36) src/Mdfwriter.cpp src/Mdfwriter.h src/CanMessage.cpp src/CanMessage.h ) - set_target_properties(mdflibrary PROPERTIES COMMON_LANGUAGE_RUNTIME "") else() add_library(mdflibrary SHARED src/MdfExport.cpp) diff --git a/mdflibrary_example/CMakeLists.txt b/mdflibrary_example/CMakeLists.txt index 05491fa3..e4253e8e 100644 --- a/mdflibrary_example/CMakeLists.txt +++ b/mdflibrary_example/CMakeLists.txt @@ -1,6 +1,5 @@ # Copyright 2023 Simplxs # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.20) project( mdflibraryexample VERSION 1.0 @@ -16,3 +15,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif() target_link_libraries(mdflibraryexample PRIVATE mdflibrary) + +target_include_directories( + mdflibrary PUBLIC $) \ No newline at end of file diff --git a/mdfviewer/CMakeLists.txt b/mdfviewer/CMakeLists.txt index 5b83757b..3db4c213 100644 --- a/mdfviewer/CMakeLists.txt +++ b/mdfviewer/CMakeLists.txt @@ -1,6 +1,5 @@ # Copyright 2021 Ingemar Hedvall # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.20) project( MdfViewer VERSION 1.0 @@ -9,7 +8,7 @@ project( set(CMAKE_CXX_STANDARD 20) -add_executable(mdfview +add_executable(mdfview src/mdfviewer.cpp src/mdfviewer.h src/mainframe.cpp src/mainframe.h src/mdfdocument.cpp src/mdfdocument.h @@ -36,16 +35,14 @@ target_include_directories(mdfview PRIVATE mdf if(MSVC) target_link_options(mdfview PRIVATE /SUBSYSTEM:WINDOWS) target_compile_definitions(mdfview PRIVATE _WIN32_WINNT=0x0A00) -endif() - -if(MINGW) +elseif(MINGW) target_link_options(mdfview PRIVATE -mwindows -static -fstack-protector) endif() target_link_libraries(mdfview PRIVATE mdf) if(VCPKG) - find_package(expat CONFIG REQUIRED) +find_package(expat CONFIG REQUIRED) target_link_libraries(mdfview PRIVATE expat::expat) find_package(ZLIB REQUIRED) @@ -57,7 +54,7 @@ if(VCPKG) find_package(wxWidgets CONFIG REQUIRED) target_link_libraries(mdfview PRIVATE wx::core wx::base) else() - include("../script/zlib.cmake") +include("../script/zlib.cmake") include("../script/expat.cmake") include("../script/wxwidgets.cmake") include("../script/boost.cmake")