I am setting up GLFW and Vulkan for a project of mine. For Vulkan I am using MoltenVk to get Vulkan compat and GLFW for the window creation. The IDE I am using is CLion, which uses the CMake system.
Judging from some github issues, there seems to be support for this setup, but nobody there mentions how it is done.
GLFW is installed through homebrew and MoltenVK manually by adding the MoltenVK and vulkan folders to usr/local/include and the contents of the MacOS folder to usr/local/lib (even though I am quite sure MoltenVK.framework should not be there).
At this point, Clion can see the GLFW and Vulkan headers, but I still need to link them up properly.
the full CMakeLists.txt file is this now:
cmake_minimum_required(VERSION 3.8)
project(VulkanEngine)
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} “${CMAKE_SOURCE_DIR}/cmake/Modules”)
set(CMAKE_CXX_STANDARD 17)
set(SOURCE_FILES src/main.cpp)
add_executable(VulkanEngine ${SOURCE_FILES})
#Finding and linking GLFW3
find_package(glfw3 3.2 REQUIRED)
if (glfw3_FOUND)
include_directories(${glfw3_INCLUDE_DIRS})
target_link_libraries (VulkanEngine ${glfw3_LIBRARIES})
endif (glfw3_FOUND)
#Finding and linking Vulkan
find_package (Vulkan)
if (Vulkan_FOUND)
include_directories(${Vulkan_INCLUDE_DIRS})
target_link_libraries (VulkanEngine ${Vulkan_LIBRARIES})
endif (Vulkan_FOUND)
the console tells the following when the cmake project has been reloading:
-- Could NOT find Vulkan (missing: Vulkan_LIBRARY)
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/mtesseract/dev/cpp/VulkanEngine/cmake-build-debug
to me this indicates that GLFW has been found and linked, but when I try to build the "hello world" for GLFW, I get the following message:
Undefined symbols for architecture x86_64:
"_glfwInit", referenced from:
_main in main.cpp.o
I got FindVulkan.cmake from the GLFW github page https://git.io/v5ggN, since it has support for MoltenVK, but I am not sure if it is picked up by CMake at all. (I put the file in (projectroot)/cmake/modules/)
At this point, I am out of ideas as to why things are not linking properly, so help is appreciated.
I have found a solution that at least till some degree seems to work. At this point I have another problem to take care of (GLFW doesn't seem to pick up on MoltenVK's presence).
The process thus far is as follows (and can be found on my github page (github.com/mtesseracttech/VulkanEngine):
I am pretty sure this solution is not ideal since GLFW isn't picking up on MoltenVK with this tactic, but at least things compile, so I see that as progress.