Skip to content
Permalink
Browse files

Fix QCA-ssl for FreeBSD

  • Loading branch information
lbartoletti authored and nyalldawson committed May 31, 2018
1 parent a26b9b1 commit 25ba36180cfbf836b9458beb98e28f62349c4260
Showing with 3 additions and 2 deletions.
  1. +3 −2 cmake/QCAMacros.cmake
@@ -12,8 +12,9 @@

function(FIND_QCAOSSL_PLUGIN_CPP PLUGIN_REQUIRED)

FIND_PACKAGE(Qt5Core QUIET)
# requires Qt and QCA packages to be found
if(QT_INCLUDE_DIR AND QT_QTCORE_INCLUDE_DIR AND Qt5Core_LIBRARIES
if(Qt5Core_INCLUDE_DIRS AND Qt5Core_LIBRARIES
AND QCA_INCLUDE_DIR AND QCA_LIBRARY
AND NOT CMAKE_CROSSCOMPILING)

@@ -92,7 +93,7 @@ function(FIND_QCATOOL TOOL_REQUIRED)
$ENV{OSGEO4W_ROOT}/bin
)
else()
find_program(QCATOOL_EXECUTABLE NAMES qcatool qcatool2 qcatool-qt5)
find_program(QCATOOL_EXECUTABLE NAMES qcatool-qt5 qcatool2 qcatool)
endif()

if(NOT QCATOOL_EXECUTABLE)

7 comments on commit 25ba361

@rouault

This comment has been minimized.

Copy link
Contributor

@rouault rouault replied May 31, 2018

@lbartoletti This breaks the build for me on Ubuntu 16.04 with

Run Build Command:"/usr/bin/make" "cmTC_3b936/fast"
make[1] : on entre dans le répertoire « /home/even/qgis/QGIS/build/CMakeFiles/CMakeTmp »
/usr/bin/make -f CMakeFiles/cmTC_3b936.dir/build.make CMakeFiles/cmTC_3b936.dir/build
make[2] : on entre dans le répertoire « /home/even/qgis/QGIS/build/CMakeFiles/CMakeTmp »
Building CXX object CMakeFiles/cmTC_3b936.dir/qcaossl.cpp.o
/usr/bin/c++    -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I/usr/include/Qca-qt5/QtCrypto  -fPIE   -std=gnu++11 -o CMakeFiles/cmTC_3b936.dir/qcaossl.cpp.o -c /home/even/qgis/QGIS/build/CMakeFiles/CMakeTmp/qcaossl.cpp
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qchar.h:37:0,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:41,
                 from /usr/include/x86_64-linux-gnu/qt5/QtCore/QString:1,
                 from /usr/include/Qca-qt5/QtCrypto/qca_core.h:36,
                 from /usr/include/Qca-qt5/QtCrypto/qca.h:36,
                 from /usr/include/Qca-qt5/QtCrypto/QtCrypto:1,
                 from /home/even/qgis/QGIS/build/CMakeFiles/CMakeTmp/qcaossl.cpp:2:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qglobal.h:1067:4: error: #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC (-fPIE is not enough)."
 #  error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\
    ^
CMakeFiles/cmTC_3b936.dir/build.make:65 : la recette pour la cible « CMakeFiles/cmTC_3b936.dir/qcaossl.cpp.o » a échouée
make[2]: *** [CMakeFiles/cmTC_3b936.dir/qcaossl.cpp.o] Erreur 1
make[2] : on quitte le répertoire « /home/even/qgis/QGIS/build/CMakeFiles/CMakeTmp »
Makefile:126 : la recette pour la cible « cmTC_3b936/fast » a échouée
make[1]: *** [cmTC_3b936/fast] Erreur 2
make[1] : on quitte le répertoire « /home/even/qgis/QGIS/build/CMakeFiles/CMakeTmp »

CMake Error at cmake/QCAMacros.cmake:62 (message):
  QCA OpenSSL plugin not found (run-time/unit-test dependency)
Call Stack (most recent call first):
  CMakeLists.txt:361 (FIND_QCAOSSL_PLUGIN_CPP)

Reverting it makes the build work again.
Apparently the issue is due to -DCMAKE_POSITION_INDEPENDENT_CODE=ON being translated as -fPIE instead of -fPIC

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied May 31, 2018

@rouault does it work if you remove cmake/QCAMacros.cmake, line 48 (the PIC line)?

@rouault

This comment has been minimized.

Copy link
Contributor

@rouault rouault replied May 31, 2018

Nope. If I remove -DCMAKE_POSITION_INDEPENDENT_CODE=ON, then c++ is invoked without -fPIE nor -fPIC, and the result of the compilation is the same error

@jgrocha

This comment has been minimized.

Copy link
Member

@jgrocha jgrocha replied May 31, 2018

Same problem here on Ubuntu 18.04: "Compile your code with -fPIC (-fPIE is not enough)."

@jgrocha

This comment has been minimized.

Copy link
Member

@jgrocha jgrocha replied May 31, 2018

I've just added:
set(CMAKE_CXX_FLAGS "-fPIC")
to QCAMacros.cmake and it works now. I'm not sure if this fixes the problem for all Qt installations.

I have now:

    set(QCA_INCLUDE_DIRECTORIES "-DINCLUDE_DIRECTORIES:STRING=${Qt5Core_INCLUDE_DIRS};${QCA_INCLUDE_DIR}")
    get_target_property(_QtCore_path Qt5::Core LOCATION)
    set(QCA_LINK_LIBRARIES "-DLINK_LIBRARIES:STRING=${_QtCore_path};${QCA_LIBRARY}")
    set(CMAKE_CXX_FLAGS "-fPIC")
    try_run(RUN_RESULT COMPILE_RESULT
      ${CMAKE_BINARY_DIR} ${TESTCPP}
      CMAKE_FLAGS "-DCMAKE_CXX_STANDARD=11"
                  "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
                  "${QCA_INCLUDE_DIRECTORIES}"
                  "${QCA_LINK_LIBRARIES}"
      COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
    )

@rouault Can you check if this works for you Even?

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied May 31, 2018

@jgrocha see also #6093 (comment)

@rouault

This comment has been minimized.

Copy link
Contributor

@rouault rouault replied May 31, 2018

@jgrocha
No, your proposal doesn't work for me. It generates a " -fPIC -fPIE" compilation line, and qtglobal.h doesn't like at all the -fPIE.

Please sign in to comment.
You can’t perform that action at this time.