1
General / Issue with linking to SFGUI, cmake is generating incorrect path to lib file.
« on: November 12, 2018, 04:58:21 am »
Looks like there used to be an SFGUI forum but not anymore? If this is the wrong place to post this let me know and I'll post it elsewhere.
I'm a bit stuck with an issue trying to build a simple test program using SFML and SFGUI. This is on Windows, and I've used cmake to generate Visual Studio 2017 projects.
First I cloned SFML SFGUI from github and generated the solution files. I ran Visual Studio in administrator mode and build the INSTALL project with both release and debug targets so that they would all be built and dropped in C:\Program Files (x86)\SFML\ and C:\Program Files (x86)\SFGUI\ respectively. Everything built and installed fine right out of the box. I also added those two directories to my PATH environment variable. I can build and run the sample projects that come with SFGUI that show up in the solution file.
So now I go and create my own project, and things start to fall apart. Importing SFML itself works fine. I have a simple program that pops open a window and it works fine. When I add in find_package(SFGUI REQUIRED) CMake fails when the project tries to update. I get the following error:
2>CMake Error at C:/Program Files (x86)/SFGUI/cmake/SFGUITargets.cmake:78 (message):
2> The imported target "SFGUI::SFGUI" references the file
2>
2> "C:/Program Files (x86)/lib/SFGUI-d.lib"
2>
2> but this file does not exist. Possible reasons include:
2>
2> * The file was deleted, renamed, or moved to another location.
2>
2> * An install or uninstall procedure did not complete successfully.
2>
2> * The installation package was faulty and contained
2>
2> "C:/Program Files (x86)/SFGUI/cmake/SFGUITargets.cmake"
2>
2> but not all the files it references.
Notice in the error, the file is "C:/Program Files (x86)/lib/SFGUI-d.lib" and not "C:/Program Files (x86)/SFGUI/lib/SFGUI-d.lib"
Looking at the SFGUI cmake files, it looks like the variable _IMPORT_PREFIX is being set to C:/Program Files (x86)/, when I think it should be setting set to C:/Program Files (x86)/SFGUI. I think that variable is getting set by the call to set_target_properties in SFGUITargets[-debug].cmake. I'm not sure if this is the core issue, or if it is, why it's getting set wrong. Any ideas what I did wrong?
Here is the entirety of my CMakeLists.txt in case it helps:
cmake_minimum_required(VERSION 3.1)
set(PROJECT_NAME TestProj)
project(${PROJECT_NAME})
set(SOURCES src/main.cpp)
find_package(OpenGL REQUIRED)
find_package(SFML 2.5 REQUIRED COMPONENTS graphics window audio network system)
find_package(SFGUI REQUIRED)
add_executable(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}
sfml-graphics
sfml-window
sfml-audio
sfml-network
sfml-system)
I'm a bit stuck with an issue trying to build a simple test program using SFML and SFGUI. This is on Windows, and I've used cmake to generate Visual Studio 2017 projects.
First I cloned SFML SFGUI from github and generated the solution files. I ran Visual Studio in administrator mode and build the INSTALL project with both release and debug targets so that they would all be built and dropped in C:\Program Files (x86)\SFML\ and C:\Program Files (x86)\SFGUI\ respectively. Everything built and installed fine right out of the box. I also added those two directories to my PATH environment variable. I can build and run the sample projects that come with SFGUI that show up in the solution file.
So now I go and create my own project, and things start to fall apart. Importing SFML itself works fine. I have a simple program that pops open a window and it works fine. When I add in find_package(SFGUI REQUIRED) CMake fails when the project tries to update. I get the following error:
2>CMake Error at C:/Program Files (x86)/SFGUI/cmake/SFGUITargets.cmake:78 (message):
2> The imported target "SFGUI::SFGUI" references the file
2>
2> "C:/Program Files (x86)/lib/SFGUI-d.lib"
2>
2> but this file does not exist. Possible reasons include:
2>
2> * The file was deleted, renamed, or moved to another location.
2>
2> * An install or uninstall procedure did not complete successfully.
2>
2> * The installation package was faulty and contained
2>
2> "C:/Program Files (x86)/SFGUI/cmake/SFGUITargets.cmake"
2>
2> but not all the files it references.
Notice in the error, the file is "C:/Program Files (x86)/lib/SFGUI-d.lib" and not "C:/Program Files (x86)/SFGUI/lib/SFGUI-d.lib"
Looking at the SFGUI cmake files, it looks like the variable _IMPORT_PREFIX is being set to C:/Program Files (x86)/, when I think it should be setting set to C:/Program Files (x86)/SFGUI. I think that variable is getting set by the call to set_target_properties in SFGUITargets[-debug].cmake. I'm not sure if this is the core issue, or if it is, why it's getting set wrong. Any ideas what I did wrong?
Here is the entirety of my CMakeLists.txt in case it helps:
cmake_minimum_required(VERSION 3.1)
set(PROJECT_NAME TestProj)
project(${PROJECT_NAME})
set(SOURCES src/main.cpp)
find_package(OpenGL REQUIRED)
find_package(SFML 2.5 REQUIRED COMPONENTS graphics window audio network system)
find_package(SFGUI REQUIRED)
add_executable(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER ${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME}
sfml-graphics
sfml-window
sfml-audio
sfml-network
sfml-system)