Skip to content

Commit

Permalink
Prepare for report server build. Simplify boost version change. Alway…
Browse files Browse the repository at this point in the history
…s build google test.
  • Loading branch information
ihedvall committed Jan 28, 2024
1 parent 9c7a6fe commit 965d565
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: CMAKE Configure
run: >
cmake -B ${{github.workspace}}/build
-D MDF_BUILD_TOOL=OFF -D MDF_BUILD_TEST=ON -D MDF_BUILD_SHARED_LIB=OFF
-D MDF_BUILD_TOOL=OFF -D MDF_BUILD_TEST=ON -D MDF_BUILD_SHARED_LIB=ON
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-D CMAKE_TOOLCHAIN_FILE=${{env.VCPKG_FILE}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmake_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: CMAKE Configure
run: >
cmake -B ${{github.workspace}}/build
-D MDF_BUILD_TOOL=OFF -D MDF_BUILD_TEST=OFF -D MDF_BUILD_SHARED_LIB=OFF
-D MDF_BUILD_TOOL=OFF -D MDF_BUILD_TEST=OFF -D MDF_BUILD_SHARED_LIB=ON
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-D CMAKE_TOOLCHAIN_FILE=${{env.VCPKG_FILE}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmake_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: CMAKE Configure
run: >
cmake -B ${{github.workspace}}/build
-D MDF_BUILD_TOOL=ON -D MDF_BUILD_TEST=ON -D MDF_BUILD_SHARED_LIB=OFF
-D MDF_BUILD_TOOL=ON -D MDF_BUILD_TEST=ON -D MDF_BUILD_SHARED_LIB=ON
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-D CMAKE_TOOLCHAIN_FILE=${{env.VCPKG_FILE}}
Expand Down
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/.idea.mdflib.dir/.idea/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/.idea.mdflib.dir/.idea/encodings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/.idea.mdflib.dir/.idea/indexLayout.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/.idea.mdflib.dir/.idea/vcs.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/.idea.mdflib/.idea/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/.idea.mdflib/.idea/encodings.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/.idea.mdflib/.idea/indexLayout.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/.idea.mdflib/.idea/vcs.xml

This file was deleted.

10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ else()
set(VCPKG ON)
endif()

option(BUILD_SHARED_LIBS "Build static library as default." OFF)
option(MDF_BUILD_SHARED_LIB "Build shared library." ON)
option(MDF_BUILD_SHARED_LIB_NET "Build shared library with .NET." OFF) # Only for MSVC 19.36+
option(MDF_BUILD_SHARED_LIB_EXAMPLE "Build MdfLibrary Example." OFF)
option(MDF_BUILD_SHARED_LIB_NET "Build shared library with .NET." OFF)
option(MDF_BUILD_SHARED_LIB_EXAMPLE "Build shared library 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)
option(MDF_BUILD_TEST "Build Google Unit Tests. Requires Google Test." OFF)

if(MDF_BUILD_TOOL AND VCPKG)
# Boost & wxWidgets need /MT for static linking
# string(REPLACE "-static" "" 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 need /MT for static linking
# string(REPLACE "-static" "" VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}")
Expand All @@ -27,7 +31,7 @@ endif()

project(
mdflib
VERSION 2.0
VERSION 2.1
DESCRIPTION "Interface against MDF 3/4 files"
LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion include/mdf/mdfreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class MdfReader {
/** \brief Returns the header (HD) block. */
[[nodiscard]] const IHeader* GetHeader() const;
/** \brief Returns the data group (DG) block. */
[[nodiscard]] const IDataGroup* GetDataGroup(size_t order) const;
[[nodiscard]] IDataGroup* GetDataGroup(size_t order) const;

[[nodiscard]] std::string ShortName()
const; ///< Returns the file name without paths.
Expand Down
5 changes: 4 additions & 1 deletion mdflib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_DEBUG_POSTFIX d)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

add_library(mdf STATIC
add_library(mdf
src/mdfblock.cpp src/mdfblock.h
src/mdffile.cpp ../include/mdf/mdffile.h
src/idblock.cpp src/idblock.h
Expand Down Expand Up @@ -148,6 +149,8 @@ set_target_properties(mdf PROPERTIES PUBLIC_HEADER "${MDF_PUBLIC_HEADERS}")
get_target_property(PH1 mdf PUBLIC_HEADER)
message(STATUS "MDF Target Includes: " "${PH1}")



if(WIN32)
install(
TARGETS mdf
Expand Down
2 changes: 1 addition & 1 deletion mdflib/src/mdfreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ const IHeader *MdfReader::GetHeader() const {
return file != nullptr ? file->Header() : nullptr;
}

const IDataGroup *MdfReader::GetDataGroup(size_t order) const {
IDataGroup *MdfReader::GetDataGroup(size_t order) const {
const auto *file = GetFile();
if (file != nullptr) {
DataGroupList dg_list;
Expand Down
1 change: 0 additions & 1 deletion mdflib_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ else()
target_link_libraries(test_mdf PRIVATE ${Boost_LIBRARIES})

include("../script/googletest.cmake")
target_include_directories(test_mdf PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(test_mdf PRIVATE GTest::gtest GTest::gtest_main)
endif()

Expand Down
2 changes: 1 addition & 1 deletion script/boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (NOT Boost_FOUND)
set(Boost_DEBUG OFF)

if (COMP_DIR)
set(Boost_ROOT ${COMP_DIR}/boost/boost_1_80_0)
set(Boost_ROOT ${COMP_DIR}/boost/latest)
endif()

find_package(Boost REQUIRED COMPONENTS filesystem system locale program_options)
Expand Down
25 changes: 12 additions & 13 deletions script/googletest.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Copyright 2021 Ingemar Hedvall
# SPDX-License-Identifier: MIT

if (NOT GTest_FOUND)
set(GTEST_MSVC_SEARCH MT)
if (COMP_DIR)
# Ignore the error message that GTest_ROOT should be used. It has to be capital letters
set(GTEST_ROOT ${COMP_DIR}/googletest/master)
endif()
include (FetchContent)

find_package(GTest)
message(STATUS "GTest Found: " ${GTest_FOUND})
message(STATUS "GTest Include Dirs: " ${GTEST_INCLUDE_DIRS})
message(STATUS "GTest Libraries: " ${GTEST_LIBRARIES})
message(STATUS "GTest Main Libraries: " ${GTEST_MAIN_LIBRARIES})
message(STATUS "GTest Both Libraries: " ${GTEST_BOTH_LIBRARIES})
endif()
include(FetchContent)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG HEAD
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
message(STATUS "googletest Populated: " ${googletest_POPULATED})
message(STATUS "googletest Source: " ${googletest_SOURCE_DIR})
message(STATUS "googletest Binary: " ${googletest_BINARY_DIR})
49 changes: 25 additions & 24 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "mdflib",
"version": "2.1",
"dependencies": [
"zlib",
"expat"
],
"features": {
"mdfviewer": {
"description": "Build mdf viewer",
"dependencies": [
"boost-process",
"boost-locale",
"wxwidgets"
]
},
"mdflibtest": {
"description": "Build mdf tests",
"dependencies": [
"boost-endian",
"gtest"
]
}
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "mdflib",
"version": "2.1",
"dependencies": [
"zlib",
"expat"
],
"features": {
"mdfviewer": {
"description": "Build mdf viewer",
"dependencies": [
"boost-process",
"boost-locale",
"wxwidgets"
]
},
"mdflibtest": {
"description": "Build mdf tests",
"dependencies": [
"boost-endian",
"gtest"
]
}
}
},
"builtin-baseline": "2b681d95e08447fde261b4404fbeab324f7d1e5b"
}

0 comments on commit 965d565

Please sign in to comment.