Skip to content

Commit 88a1cf4

Browse files
committed
Update to Conan 2
1 parent 2156239 commit 88a1cf4

File tree

8 files changed

+43
-99
lines changed

8 files changed

+43
-99
lines changed

CMakeLists.txt

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
2626

2727
set(generatedSourcesDir "${CMAKE_BINARY_DIR}/generated")
2828

29-
set(Boost_USE_STATIC_LIBS ON)
30-
3129
if (MSVC)
3230
add_definitions("-D_WIN32_WINNT=0x600" "-D_CRT_SECURE_NO_WARNINGS")
3331
add_compile_options("/wd4996" "/wd4251" "/wd4244" "/wd4267")
@@ -57,13 +55,8 @@ set(PROXYFMU_EXPORT_TARGET "${PROJECT_NAME}-targets")
5755
# Dependencies
5856
# ==============================================================================
5957

60-
if (CONAN_EXPORTED) # in conan local cache
61-
# standard conan installation, deps will be defined in conanfile.py
62-
# and not necessary to call conan again, conan is already running
63-
# include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
64-
# conan_basic_setup()
65-
else ()
66-
58+
if (NOT CONAN_EXPORTED)
59+
# Conan is not already running, so run it to get dependencies.
6760
include(cmake/conan.cmake)
6861
conan_check(REQUIRED)
6962

@@ -75,7 +68,6 @@ else ()
7568
BUILD missing
7669
SETTINGS ${settings}
7770
BASIC_SETUP)
78-
7971
endif ()
8072

8173
set(BOOST_COMPONENTS filesystem)
@@ -93,8 +85,8 @@ endif ()
9385

9486
find_package(Boost 1.71 COMPONENTS ${BOOST_COMPONENTS} REQUIRED)
9587
find_package(CLI11 REQUIRED)
96-
find_package(THRIFT REQUIRED)
97-
find_package(FMILIB REQUIRED)
88+
find_package(Thrift REQUIRED)
89+
find_package(FMILIB MODULE REQUIRED)
9890

9991

10092
# ==============================================================================
@@ -147,9 +139,7 @@ install(FILES "${versionFile}" DESTINATION "${PROXYFMU_CMAKE_INSTALL_DIR}")
147139

148140
# Install custom find modules
149141
install(FILES
150-
"${CMAKE_SOURCE_DIR}/cmake/FindCLI11.cmake"
151142
"${CMAKE_SOURCE_DIR}/cmake/FindFMILIB.cmake"
152-
"${CMAKE_SOURCE_DIR}/cmake/FindTHRIFT.cmake"
153143
DESTINATION
154144
"${PROXYFMU_CMAKE_INSTALL_DIR}"
155145
)

cmake/FindCLI11.cmake

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

cmake/FindTHRIFT.cmake

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

cmake/project-config.cmake.in

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ include(CMakeFindDependencyMacro)
66
list(APPEND CMAKE_MODULE_PATH "${PACKAGE_PREFIX_DIR}/@PROXYFMU_CMAKE_INSTALL_DIR@")
77

88
find_dependency(Boost COMPONENTS filesystem REQUIRED)
9-
10-
find_dependency(FMILIB REQUIRED)
11-
find_dependency(THRIFT REQUIRED)
12-
find_dependency(CLI11 REQUIRED)
9+
find_dependency(FMILIB MODULE REQUIRED)
10+
find_dependency(Thrift REQUIRED)
1311

1412
list(REMOVE_AT CMAKE_MODULE_PATH -1)

conanfile.py

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
1-
import os
1+
from os import path
22

33
from conan import ConanFile
4-
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
4+
from conan.tools.cmake import CMake
55
from conan.tools.files import load
66

77

88
class ProxyFmuConan(ConanFile):
99
name = "proxyfmu"
10+
def set_version(self):
11+
self.version = load(self, path.join(self.recipe_folder, "version.txt")).strip()
12+
1013
author = "osp"
1114
license = "MIT"
12-
exports = "version.txt"
13-
exports_sources = "CMakeLists.txt", "version.txt", "src/*", "include/*", "cmake/*", "data*", "tests/*", "tool/*"
15+
url = "https://github.com/open-simulation-platform/proxy-fmu"
16+
17+
package_type = "library"
1418
settings = "os", "compiler", "build_type", "arch"
15-
generators = "CMakeDeps"
16-
requires = (
17-
"cli11/2.3.1",
18-
"fmilibrary/2.3",
19-
"thrift/0.13.0"
20-
)
2119
options = {
22-
"shared": [True, False]
20+
"shared": [True, False],
21+
"fPIC": [True, False]
2322
}
2423
default_options = {
25-
"shared": True
24+
"shared": True,
25+
"fPIC": True
2626
}
2727

28-
def set_version(self):
29-
self.version = load(self, os.path.join(self.recipe_folder, "version.txt")).strip()
28+
tool_requires = "thrift/[~0.13]" # Thrift compiler
29+
requires = (
30+
"boost/[>=1.71]",
31+
"cli11/[~2.3]",
32+
"fmilibrary/[~2.3]",
33+
"thrift/[~0.13]"
34+
)
35+
36+
exports = "version.txt"
37+
exports_sources = "*"
38+
39+
generators = "CMakeDeps", "CMakeToolchain"
3040

31-
def layout(self):
32-
cmake_layout(self)
41+
def config_options(self):
42+
if self.settings.os == "Windows":
43+
del self.options.fPIC
3344

34-
def generate(self):
35-
tc = CMakeToolchain(self)
36-
tc.cache_variables["BUILD_SHARED_LIBS"] = self.options.shared
37-
tc.cache_variables["CONAN_EXPORTED"] = True
38-
tc.generate()
45+
def configure(self):
46+
if self.options.shared:
47+
self.options.rm_safe("fPIC")
3948

4049
def build(self):
4150
cmake = CMake(self)
@@ -48,4 +57,6 @@ def package(self):
4857

4958
def package_info(self):
5059
self.cpp_info.libs = ["proxyfmu-client"]
51-
self.cpp_info.defines = ["Boost_USE_STATIC_LIBS=ON"]
60+
# Tell consumers to use "our" CMake package config file.
61+
self.cpp_info.builddirs.append(".")
62+
self.cpp_info.set_property("cmake_find_mode", "none")

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ target_include_directories(proxyfmu-client
121121
target_link_libraries(proxyfmu-client
122122
PUBLIC
123123
fmilibwrapper
124-
PRIVATE
124+
#PRIVATE # Temporarily disabled due to https://github.com/conan-io/conan/issues/13302
125125
thrift::thrift
126126
Boost::filesystem
127127
)

src/proxyfmu/fmi/fmicontext.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "fmilib.h"
66

7+
#include <cstdlib>
8+
#include <cstdio>
79
#include <cstring>
810
#include <memory>
911

src/thrift/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set(thriftGenerated
4545
)
4646

4747
add_library(proxyfmu-service OBJECT ${thriftGenerated})
48+
target_link_libraries(proxyfmu-service PUBLIC thrift::thrift)
4849
set_target_properties(proxyfmu-service PROPERTIES POSITION_INDEPENDENT_CODE ON)
4950

5051

0 commit comments

Comments
 (0)