Skip to content

Commit

Permalink
qwt: Updated test_package to work with both QT 5 & 6
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-b committed Nov 27, 2023
1 parent f2eaa70 commit 8370fcf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
18 changes: 15 additions & 3 deletions recipes/qwt/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(qwt REQUIRED CONFIG)
find_package(Qt5 REQUIRED Core CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE qwt::qwt Qt5::Core)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)

if(QT_VERSION VERSION_GREATER_EQUAL "6.0.0")
find_package(Qt6 REQUIRED COMPONENTS Core CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
elseif(QT_VERSION VERSION_GREATER_EQUAL "5.0.0")
find_package(Qt5 COMPONENTS Core REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
else()
message(FATAL_ERROR "Qt < 5 is not supported by this recipe")
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE qwt::qwt)

if(NOT WIN32)
# Must compile with "-fPIC" since Qt was built with -reduce-relocations.
target_compile_options(${PROJECT_NAME} PRIVATE -fPIC)
Expand Down
9 changes: 7 additions & 2 deletions recipes/qwt/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
Expand All @@ -15,6 +15,11 @@ def layout(self):
def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["QT_VERSION"] = self.dependencies["qt"].ref.version
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
Expand Down

0 comments on commit 8370fcf

Please sign in to comment.