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 remake #181

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

CMake remake #181

wants to merge 3 commits into from

Conversation

gaurapanasenko
Copy link

Now it is easy to pack library with cpack and use library with:

find_package(cimgui REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CIMGUI_LIBRARIES})

Now it is easy to pack library with cpack and use library with:
```cmake
find_package(cimgui REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE ${CIMGUI_LIBRARIES})
```
@sonoro1234
Copy link
Contributor

sonoro1234 commented Feb 22, 2021

compilation with Freetype gets broken for me, not only for missing PATHS ${FREETYPE_PATH} (I installed freetype to standard path but freetype is not found unless I use find_package(freetype REQUIRED PATHS ${CMAKE_PREFIX_PATH}))

If I add PATHS ${FREETYPE_PATH} the error is

C:\LuaGL\gitsources\anima\LuaJIT-ImGui\cimgui\imgui\misc\freetype\imgui_freetype.cpp:35:10: fatal error: ft2build.h: No such file or directory
 #include <ft2build.h>
          ^~~~~~~~~~~~

It is only solved by list(APPEND IMGUI_LIBRARIES freetype)

@sonoro1234
Copy link
Contributor

For being backward compatible this should be used

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../imgui/backends)
	set(BAKENDS_FOLDER "../imgui/backends/")
else()
	set(BAKENDS_FOLDER "../imgui/examples/")
endif()

As found in https://github.com/cimgui/cimgui/blob/master/backend_test/CMakeLists.txt

@gaurapanasenko
Copy link
Author

If I add PATHS ${FREETYPE_PATH} the error is

C:\LuaGL\gitsources\anima\LuaJIT-ImGui\cimgui\imgui\misc\freetype\imgui_freetype.cpp:35:10: fatal error: ft2build.h: No such file or directory
 #include <ft2build.h>
          ^~~~~~~~~~~~

You got compile error when including header file. This is why I added:

list(APPEND IMGUI_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})

Did you copied header files to ${CMAKE_PREFIX_PATH} when you was installing Freetype?

@sonoro1234
Copy link
Contributor

sonoro1234 commented Feb 22, 2021

You got compile error when including header file. This is why I added:

list(APPEND IMGUI_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})

Not working for me

Did you copied header files to ${CMAKE_PREFIX_PATH} when you was installing Freetype?

Yes. I did the cmake installation as explained in CMakeLists.txt from freetype: https://github.com/freetype/freetype2.git

first: cmake -G"MinGW Makefiles" -B build -D BUILD_SHARED_LIBS=true -D CMAKE_BUILD_TYPE=Release ../../freetype2
second:cmake --build build --target install

@gaurapanasenko
Copy link
Author

@sonoro1234 I got exactly same compile error when tried to add PATHS in find_package. I tried also ${CMAKE_SYSTEM_PREFIX_PATH}. So for now I appended FREETYPE_PATH to CMAKE_SYSTEM_PREFIX_PATH because cmake documentation says that this variable is used by find_package but not sure that it will work for you.
What environment you use for compilation? I use OpenSUSE Tumbleweed and tried prebuild freetype package and custom build freetype package with cpack and all works good. Later I can try to compile and pack it on Windows with MSYS2.

@sonoro1234
Copy link
Contributor

sonoro1234 commented Feb 22, 2021

I have been using https://github.com/freetype/freetype2.git with mingw-w64 without MSYS.
I seems outdated so I used https://gitlab.freedesktop.org/freetype/freetype but it fails to run cmake (posted an issue there and is already solved)

I used FREETYPE_PATH to point to a non standard installation directory, so it should not be necessary with a standard installation but in both cases find_package is failing unless I add PATHS.

For solving the two issues (find freetype and avoid compile errors) only this is working for me

	find_package(freetype REQUIRED PATHS ${CMAKE_SYSTEM_PREFIX_PATH})
	#list(APPEND IMGUI_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
	list(APPEND IMGUI_LIBRARIES freetype)
	list(APPEND IMGUI_SOURCES imgui/misc/freetype/imgui_freetype.cpp)
	add_definitions("-DCIMGUI_FREETYPE=1")

second line (commented as does not help), freetype succeds but Freetype not.
list(APPEND IMGUI_LIBRARIES freetype) solves the include issue.

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

Successfully merging this pull request may close these issues.

None yet

2 participants