STORM-IRIT / Radium-Engine

Research 3D Engine for rendering, animation and processing
https://storm-irit.github.io/Radium-Engine/
Apache License 2.0
100 stars 50 forks source link

Unable to compile in debug mode on MacOsX #547

Closed MathiasPaulin closed 4 years ago

MathiasPaulin commented 4 years ago

On MacOs, glbinding and globjects are not compiled with the same compiler than the Radium libs. These two external libraries are compiled using the system default compiler (Apple Clang) whatever the compiler used by Radium (set using -DCMAKE_CXX_COMPILER= ...).

This results in an unexpected ABI conflict and link error related to CXX11 string ABI.

dlyr commented 4 years ago

According to this stackoverflow discussion Might be a good solution tu add

# MUST be done before call to 'project'
get_cmake_property(vars CACHE_VARIABLES)
foreach(var ${vars})
  get_property(currentHelpString CACHE "${var}" PROPERTY HELPSTRING)
    if("${currentHelpString}" MATCHES "No help, variable specified on the command line." OR "${currentHelpString}" STREQUAL "")
        # message("${var} = [${${var}}]  --  ${currentHelpString}") # uncomment to see the variables being processed
        list(APPEND CL_ARGS "-D${var}=${${var}}")
    endif()
endforeach()

To prevent external project to get computed cmake values in a different way than Radium's cmake do. (warning this proposal has not been tested).

MathiasPaulin commented 4 years ago

This might help, sure. But this capture all the arguments passed on the command line, even those that are Radium internals and that will never concern an external project, or, even worse, be in conflict with external project internal variables (e.g. -DRADIUM_INSTALL_DOC=OFF;-DRADIUM_IO_ASSIMP=ON;-DRADIUM_UPDATE_VERSION=OFF)

But something similar could be written to capture only some variables and pass them to the external project. I think about, mainly, the build and install configuration :

CMAKE_INSTALL_PREFIX
CMAKE_BUILD_TYPE
CMAKE_PREFIX_PATH
CMAKE_CXX_COMPILER
CMAKE_C_COMPILER

but also some variable that allows to set which external to use (compiled with Radium, installed system wide, installed in user space) such that

glm_DIR
Eigen3_DIR
Assimp_DIR
Qt5_DIR
OpenMesh_DIR
...

these Package_DIR variables are used by cmake when doing a FindPackage(Package) and might also allow to choose the correct dependance instead of always compiling external.

dlyr commented 4 years ago

Well, the snippet only take undoc params, but it's not sufficient in our case (I have tested, and the CMAKE_CXX_COMPILER is not captured) Your second suggestion refer to #544, and yes, these option if provided should be passed to other externalprojects.

MathiasPaulin commented 4 years ago

The snippet capture everything for me. Even CMAKE_CXX_COMPILER I've put it on the main CMakeLists.txt.

nmellado commented 4 years ago

As it seems to be platform/version dependent, I suggest we use a conservative approach and capture explicitly the parameters we need.

MathiasPaulin commented 4 years ago

When inserting the snippet just before the project() command in the top level CMakeLists.txt, I have the following result :

/opt/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DQt5_DIR=/Developer/Qt/5.12.3/clang_64/lib/cmake/Qt5 -DCMAKE_CXX_COMPILER=/opt/local/bin/g++ -DCMAKE_C_COMPILER=/opt/local/bin/gcc -DRADIUM_IO_ASSIMP=ON -DRADIUM_INSTALL_DOC=OFF -DRADIUM_UPDATE_VERSION=OFF -G "CodeBlocks - Unix Makefiles" /pathTo/Radium/Radium-Engine
--  Capture cmake options --> -DCMAKE_BUILD_TYPE=Debug;-DCMAKE_CXX_COMPILER=/opt/local/bin/g++;-DCMAKE_C_COMPILER=/opt/local/bin/gcc;-DQt5_DIR=/Developer/Qt/5.12.3/clang_64/lib/cmake/Qt5;-DRADIUM_INSTALL_DOC=OFF;-DRADIUM_IO_ASSIMP=ON;-DRADIUM_UPDATE_VERSION=OFF
MathiasPaulin commented 4 years ago

and in release :

/opt/local/bin/cmake -DCMAKE_BUILD_TYPE=Release -DQt5_DIR=/Developer/Qt/5.12.3/clang_64/lib/cmake/Qt5 -DCMAKE_CXX_COMPILER=/opt/local/bin/g++ -DCMAKE_C_COMPILER=/opt/local/bin/gcc -DRADIUM_IO_ASSIMP=ON -DRADIUM_INSTALL_DOC=OFF -DRADIUM_UPDATE_VERSION=OFF -G "CodeBlocks - Unix Makefiles" /pathTo/Radium/Radium-Engine
--  Capture cmake optiosn --> -DCMAKE_BUILD_TYPE=Release;-DCMAKE_CXX_COMPILER=/opt/local/bin/g++;-DCMAKE_C_COMPILER=/opt/local/bin/gcc;-DQt5_DIR=/Developer/Qt/5.12.3/clang_64/lib/cmake/Qt5;-DRADIUM_INSTALL_DOC=OFF;-DRADIUM_IO_ASSIMP=ON;-DRADIUM_UPDATE_VERSION=OFF
dlyr commented 4 years ago

That's very strange ... could you try to uncomment the print of the help message ? Oh I see, this is all the variable you give to cmake, but since the help string is given after the first project (all the option command) you have to move options before the snippet

dlyr commented 4 years ago

could you try this branch

dlyr commented 4 years ago

well it didn't work :(

MathiasPaulin commented 4 years ago

Solved by using the right assimp tag.