Skip to content

Commit

Permalink
Fix QCA-ssl for FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti authored and nyalldawson committed May 31, 2018
1 parent a26b9b1 commit 25ba361
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmake/QCAMacros.cmake
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

7 comments on commit 25ba361

@rouault
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Member

@m-kuhn m-kuhn commented on 25ba361 May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@rouault
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jgrocha
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

@m-kuhn m-kuhn commented on 25ba361 May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rouault
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.