g-truc / glm

OpenGL Mathematics (GLM)

Home Page:https://glm.g-truc.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CMake: can't import GLM 1.0.0-light

clementperon opened this issue · comments

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

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.

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

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.

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>