Skip to content

Commit 8c399a3

Browse files
authored
Replace conan with vcpkg (#139)
1 parent d5f7147 commit 8c399a3

File tree

10 files changed

+73
-236
lines changed

10 files changed

+73
-236
lines changed

.github/workflows/config.yml

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,84 +3,94 @@ name: FMI4cpp CI
33
on: [ push, workflow_dispatch ]
44

55
jobs:
6-
conan-on-linux:
6+
7+
cmake-on-linux:
78

89
runs-on: ${{ matrix.os }}
9-
env:
10-
CC: gcc-${{ matrix.compiler_version }}
11-
CXX: g++-${{ matrix.compiler_version }}
1210
strategy:
1311
fail-fast: false
1412
matrix:
1513
os: [ubuntu-20.04]
16-
compiler_version: [9]
1714

1815
steps:
19-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
2017

2118
- name: Install prerequisites
2219
run: |
23-
sudo pip3 install --upgrade setuptools pip
24-
sudo pip3 install conan
20+
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
21+
gcc g++ cmake libzip-dev libpugixml-dev
2522
2623
- name: Configure and build
2724
run: |
28-
cmake . -B build -DFMI4CPP_USING_CONAN=TRUE -DFMI4CPP_BUILD_TESTS=ON -DFMI4CPP_BUILD_EXAMPLES=ON
25+
cmake . -B build -DFMI4CPP_BUILD_TESTS=ON -DFMI4CPP_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release
2926
cmake --build build
3027
3128
- name: Test
3229
run: |
3330
cd build/tests && ctest
3431
3532
36-
conan-on-windows:
33+
vcpkg-on-linux:
3734

3835
runs-on: ${{ matrix.os }}
36+
env:
37+
CC: gcc-${{ matrix.compiler_version }}
38+
CXX: g++-${{ matrix.compiler_version }}
3939
strategy:
4040
fail-fast: false
4141
matrix:
42-
os: [windows-2019]
42+
os: [ubuntu-20.04]
43+
compiler_version: [9]
4344

4445
steps:
45-
- uses: actions/checkout@v2
46+
- uses: actions/checkout@v3
4647

47-
- name: Install prerequisites
48-
run: |
49-
pip3 install conan
50-
shell: bash
48+
- name: Restore artifacts, or run vcpkg, build (and cache artifacts as post step)
49+
uses: lukka/run-vcpkg@v10
50+
id: runvcpkg
51+
with:
52+
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
53+
vcpkgGitCommitId: '12c2a93b4007612b5ffa980c9d2235eb0bcac10f'
54+
vcpkgJsonGlob: 'vcpkg.json'
55+
appendedCacheKey: vcpkginstall
5156

5257
- name: Configure and build
5358
run: |
54-
cmake . -B build -A x64 -DFMI4CPP_USING_CONAN=TRUE -DFMI4CPP_BUILD_TESTS=ON -DFMI4CPP_BUILD_EXAMPLES=ON
55-
cmake --build build --config Release
56-
shell: bash
59+
cmake . -B build -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DFMI4CPP_BUILD_TESTS=ON -DFMI4CPP_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release
60+
cmake --build build
5761
5862
- name: Test
5963
run: |
60-
cd build/tests && ctest -C Release
61-
shell: bash
64+
cd build/tests && ctest
6265
63-
cmake-on-linux:
66+
67+
vcpkg-on-windows:
6468

6569
runs-on: ${{ matrix.os }}
6670
strategy:
6771
fail-fast: false
6872
matrix:
69-
os: [ubuntu-20.04]
73+
os: [windows-2019, windows-2022]
7074

7175
steps:
72-
- uses: actions/checkout@v2
76+
- uses: actions/checkout@v3
7377

74-
- name: Install prerequisites
75-
run: |
76-
sudo apt-get install -y --no-install-recommends \
77-
gcc g++ cmake libzip-dev libpugixml-dev
78+
- name: Restore artifacts, or run vcpkg, build (and cache artifacts as post step)
79+
uses: lukka/run-vcpkg@v10
80+
id: runvcpkg
81+
with:
82+
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
83+
vcpkgGitCommitId: '12c2a93b4007612b5ffa980c9d2235eb0bcac10f'
84+
vcpkgJsonGlob: 'vcpkg.json'
85+
appendedCacheKey: vcpkginstall
7886

7987
- name: Configure and build
8088
run: |
81-
cmake . -B build -DFMI4CPP_BUILD_TESTS=ON -DFMI4CPP_BUILD_EXAMPLES=ON
82-
cmake --build build
89+
cmake . -B build -A x64 -DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake" -DFMI4CPP_BUILD_TESTS=ON -DFMI4CPP_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=Release
90+
cmake --build build --config Release
91+
shell: bash
8392

8493
- name: Test
8594
run: |
86-
cd build/tests && ctest
95+
cd build/tests && ctest -C Release
96+
shell: bash

.github/workflows/upload.yml

Lines changed: 0 additions & 80 deletions
This file was deleted.

BUILDING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
### BUILDING
22

3-
For building FMI4cpp, you can use either `conan` or `apt-get` for getting the required dependencies.
3+
For building FMI4cpp, you can use either `vcpkg` or `apt-get` for getting the required dependencies.
44

5-
##### conan
5+
##### vcpkg
66

7-
Install [conan](https://conan.io/) and run cmake with the option `-DFMI4CPP_USING_CONAN=ON`.
7+
Call CMake with `-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake`
88

99
##### apt-get
1010

CMakeLists.txt

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ message("Current fmi4cpp version: ${projectVersion}\n")
1010

1111
option(FMI4CPP_BUILD_TESTS "Build tests" OFF)
1212
option(FMI4CPP_BUILD_EXAMPLES "Build examples" OFF)
13-
option(FMI4CPP_USING_CONAN "Build using conan" OFF)
1413
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libraries" ON)
1514

1615
set(FMI4CPP_LOG_LEVEL "DEFAULT" CACHE STRING "FMI4cpp logging level")
@@ -26,36 +25,12 @@ set(CMAKE_CXX_STANDARD 17)
2625
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
2726
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2827

28+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
29+
2930
if (NOT CMAKE_BUILD_TYPE)
3031
set(CMAKE_BUILD_TYPE "Release")
3132
endif ()
3233

33-
if (FMI4CPP_USING_CONAN)
34-
if (CONAN_EXPORTED) # in conan local cache
35-
# standard conan installation, deps will be defined in conanfile.py
36-
# and not necessary to call conan again, conan is already running
37-
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
38-
conan_basic_setup()
39-
else ()
40-
41-
include(cmake/conan.cmake)
42-
conan_cmake_autodetect(settings)
43-
44-
set(shared False)
45-
if (BUILD_SHARED_LIBS)
46-
set(shared True)
47-
endif ()
48-
49-
conan_cmake_run(
50-
CONANFILE conanfile.py
51-
OPTIONS shared=${shared}
52-
BUILD missing
53-
SETTINGS ${settings}
54-
BASIC_SETUP)
55-
56-
endif ()
57-
endif ()
58-
5934
if (MSVC)
6035
set(CMAKE_DEBUG_POSTFIX "d")
6136
add_definitions("-D_CRT_SECURE_NO_WARNINGS")

INSTALL.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ an easy to install, easy to use, object-oriented and fast FMI implementation for
1313

1414
FMI4cpp supports both **Co-simulation** and **Model Exchange**. <br/>
1515

16-
### Why should I use this over other C/C++ FMI Libraries
17-
18-
Because it provides a clean, easy to use API and is easy to install.
19-
It performs just as good as FMI Library, provides more features and is significantly easier to both build and use.
20-
21-
22-
## Install instructions
23-
24-
Refer to [INSTALL.md](INSTALL.md)
2516

2617
## Build instructions
2718

cmake/FindPugiXML.cmake

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,26 @@
55
# PUGIXML_INCLUDE_DIR - header location
66
# PUGIXML_LIBRARIES - library to link against
77
# PUGIXML_FOUND - true if pugixml was found.
8-
find_path (PUGIXML_INCLUDE_DIR NAMES pugixml.hpp PATHS ${PUGIXML_HOME}/include)
9-
find_library (PUGIXML_LIBRARY NAMES pugixml PATHS ${PUGIXML_HOME}/lib)
8+
find_path(PUGIXML_INCLUDE_DIR NAMES pugixml.hpp PATHS ${PUGIXML_HOME}/include)
9+
find_library(PUGIXML_LIBRARY NAMES pugixml PATHS ${PUGIXML_HOME}/lib)
1010

1111
# Support the REQUIRED and QUIET arguments, and set PUGIXML_FOUND if found.
12-
include (FindPackageHandleStandardArgs)
13-
FIND_PACKAGE_HANDLE_STANDARD_ARGS (PugiXML DEFAULT_MSG PUGIXML_LIBRARY
12+
include(FindPackageHandleStandardArgs)
13+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PugiXML DEFAULT_MSG PUGIXML_LIBRARY
1414
PUGIXML_INCLUDE_DIR)
1515

1616
if (PUGIXML_FOUND)
17-
set (PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
18-
message (STATUS "PugiXML include = ${PUGIXML_INCLUDE_DIR}")
19-
message (STATUS "PugiXML library = ${PUGIXML_LIBRARY}")
20-
else (PUGIXML_FOUND)
21-
message (STATUS "No PugiXML found")
22-
endif(PUGIXML_FOUND)
17+
set(PUGIXML_LIBRARIES ${PUGIXML_LIBRARY})
18+
message(STATUS "PugiXML include = ${PUGIXML_INCLUDE_DIR}")
19+
message(STATUS "PugiXML library = ${PUGIXML_LIBRARY}")
20+
else ()
21+
message(STATUS "No PugiXML found")
22+
endif ()
2323

24-
mark_as_advanced (PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)
24+
if (PUGIXML_FOUND AND NOT TARGET pugixml::pugixml)
25+
add_library(pugixml::pugixml INTERFACE IMPORTED)
26+
target_include_directories(pugixml::pugixml INTERFACE "${PUGIXML_INCLUDE_DIR}")
27+
target_link_libraries(pugixml::pugixml INTERFACE "${PUGIXML_LIBRARY}")
28+
endif ()
29+
30+
mark_as_advanced(PUGIXML_LIBRARY PUGIXML_INCLUDE_DIR)

conanfile.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)