Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: can't import GLM 1.0.0-light #1261

Open
clementperon opened this issue Feb 19, 2024 · 5 comments
Open

CMake: can't import GLM 1.0.0-light #1261

clementperon opened this issue Feb 19, 2024 · 5 comments

Comments

@clementperon
Copy link

clementperon commented Feb 19, 2024

Hi,

I have a project where I want to import GLM 1.0.0.

It was working previous with "complete source" with glm-0.9.9.8.zip

        FetchContent_Declare(
                glm
                # URL
                # https://github.com/g-truc/glm/releases/download/1.0.0/glm-1.0.0-light.zip
                URL ${CMAKE_CURRENT_SOURCE_DIR}/glm-1.0.0-light.zip
                URL_HASH
                        SHA256=bfd27ba33926fbdb341545b79e0ebc810f7b5e5593f9b0fe450cea1462950731
        )
        FetchContent_MakeAvailable(glm)

But it doesn't find the glm.hpp.
It seems that target_include_directories for the BUILD_INTERFACE is not correct

target_include_directories(glm-header-only INTERFACE
        "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
        "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

As it doesn't properly point to my "PROJECT_DIR/BUILD_DIR/_deps/glm-src/" but to "PROJECT_DIR" instead.

It's due to missing the CMakelist.txt at the root of the Zip archive which was present before.

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
cmake_policy(VERSION 3.2)

set(GLM_VERSION "0.9.9")
project(glm VERSION ${GLM_VERSION} LANGUAGES CXX)
enable_testing()

add_subdirectory(glm)
add_library(glm::glm ALIAS glm)

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})

add_subdirectory(test)

endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})

This CMakelist by calling Project() properly defined the Project Root which is not present anymore in the glm-xxx-light.zip

@xiaozhuai
Copy link

xiaozhuai commented Feb 20, 2024

Hello @clementperon. Please drop fix_include.patch into your project and edit your CMakeLists.txt

     FetchContent_Declare(
                glm
                # URL
                # https://github.com/g-truc/glm/releases/download/1.0.0/glm-1.0.0-light.zip
                URL ${CMAKE_CURRENT_SOURCE_DIR}/glm-1.0.0-light.zip
                URL_HASH
                        SHA256=bfd27ba33926fbdb341545b79e0ebc810f7b5e5593f9b0fe450cea1462950731
                PATCH_COMMAND git apply "${CMAKE_CURRENT_SOURCE_DIR}/fix_include.patch"
                UPDATE_DISCONNECTED 1
        )

If this temporary workaround works for you, I'll submit a pr to fix it.

@clementperon
Copy link
Author

clementperon commented Feb 28, 2024

Hello @xiaozhuai,

Thanks for the proposition,

Unfortunately, It doesn't fix it because the glm is extracted to

obj/dev/glm-src/glm.hpp

But source files looks to include

#include <glm/glm.hpp>

and not

#include <glm-src/glm.hpp>

I think it would be proper to have a glm folder no ?

Or I should change the name of the SOURCE_FOLDER but it's not really clean IMO

@christophe-lunarg
Copy link

Is this problem not due to the fact that the "light builds" didn't grab all the files?

I changed this with #1272 which makes the "light" builds generate zip packages the same way it used to be package, with all the files in 0.9.9.8.

@clementperon
Copy link
Author

clementperon commented Mar 5, 2024

Is this problem not due to the fact that the "light builds" didn't grab all the files?

I changed this with #1272 which makes the "light" builds generate zip packages the same way it used to be package, with all the files in 0.9.9.8.

Hi, so there is two issues:

  • First is that the light release doesn't define a new project() so the $PROJECT_SOURCE_DIR is wrong
  • Second the glm.hpp is not in a "glm" sub-folder, so when I import the Project with FetchContent() I'm not able to keep the #include <glm/glm.hpp> but I should change it to #include <glm.hpp>

@pfirsich
Copy link

pfirsich commented Sep 5, 2024

This breaks glm with FetchContent and I would be very thankful if this could be addressed.

EDIT: The real solution is not to use the light packages, but the source code zip: https://github.com/g-truc/glm/archive/refs/tags/1.0.1.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants