View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015301CMakeCMakepublic2014-12-12 12:032015-05-04 09:05
Reporterjackcmedia 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSWindowsOS Version7, 64 Bits
Product VersionCMake 3.0.2 
Target VersionFixed in Version 
Summary0015301: FIND_LIBRARY_USE_LIB64_PATHS doesn't work on Windows OSes
DescriptionSetting up a bi-arch cross-compiling script to generate 32 or 64 bit binaries on demand.

Found that FIND_LIBRARY_USE_LIB64_PATHS doesn't work on Windows, failing to locate the 64 bit libraries placed on a folder named "lib64". Renaming said folder to "lib" makes it work as intended.
Steps To Reproduce1.- Install CMake 3.0.2 (TDM-GCC's MinGW-w64 4.9.2 and CLion are my compiler and IDE of choice, but are not required).

2.- Set up SFML 2.1 64 bits, a third party library, like this:

  include
  lib64 (x64 libs)

and set the CMake (or environmental variable) SFML_ROOT pointing to the root folder of the third party library.

3.- Create a minimal CMakeLists.txt, like the following:

cmake_minimum_required(VERSION 2.8)
project(CMakeTest LANGUAGES CXX)

if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  message(WARNING "Target is 64 bits")
else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
  message(WARNING "Target is 32 bits")
endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")

set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})
find_package(SFML 2.1 REQUIRED graphics system window)

include_directories(${PROJECT_SOURCE_DIR}/)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})

if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES})
endif()

4.- Create a minimal source file, like the following:

#include <SFML/Graphics/RenderWindow.hpp>

int main() {
  sf::RenderWindow window2;
  return 0;
}

5.- Download FindSFML.cmake from https://github.com/LaurentGomila/SFML/blob/2.1/cmake/Modules/FindSFML.cmake [^] and add it to the project inside ${PROJECT_SOURCE_DIR}/cmake/Modules.

6.- Try to compile and confirm it fails to locate the libraries.

7.- Rename "lib64" to "lib" and compile again. This time, it's a success.
Tagsc++, CMake, find_library, unix, Windows 7
Attached Files

 Relationships

  Notes
(0037448)
Brad King (manager)
2014-12-12 13:22

One can see the use of FIND_LIBRARY_USE_LIB64_PATHS here:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmFindLibraryCommand.cxx;hb=v3.0.2#l58 [^]

and it depends on CMAKE_SIZEOF_VOID_P through cmMakefile::PlatformIs64Bit here:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmMakefile.cxx;hb=v3.0.2#l2367 [^]

Perhaps that will help start debugging it.
(0037449)
jackcmedia (reporter)
2014-12-13 09:15

Detecting whether a platform is 32 or 64 bits seems to work fine.

Downloaded the CMake 3.0.2 source code and started tinkering with it on a XUbuntu 14.04 64 bit VM to see what is happening. Using the minimal reproducible example I provided (assuming I have the third party libraries at /home/jack/SFML-2.1/, the x64 libraries are inside the "lib64" subfolder and FIND_LIBRARY_USE_LIB64_PATHS is enabled), among the paths considered as possible places where the libraries might be are:

/home/jack/SFML-2.1/lib64/
/home/jack/SFML-2.1/lib64/64/
/home/jack/SFML-2.1/lib/
/home/jack/SFML-2.1/lib64/
/home/jack/SFML-2.1/lib64/64/
/home/jack/SFML-2.1/lib/64/
/home/jack/SFML-2.1/
/home/jack/SFML-2.1/64/

Notice the first and third items on that list. Yet, when using make to generate the binaries, it doesn't find the libraries on the first path and, instead, complains that they cannot be found on the third path.

Doesn't seem to be OS specific. Let me check if this is how it works on Windows...
(0037455)
jackcmedia (reporter)
2014-12-14 09:17
edited on: 2014-12-14 09:18

All right, I feel like an idiot now.

FIND_LIBRARY_USE_LIB64_PATHS works on Windows. I've tested this both on Windows and Linux with the official precompiled binaries and binaries I modified to tell me, if the libraries have been found, where are them. Indeed, it finds the libraries located at the "lib64" subfolder.

The "bug" was a combination of CMake not updating the paths to the libraries and always pointing to the 32-bit libraries (I thought it would be updated), CLion not being able to delete the cache files.

So, closing this bug report. At least I learned a bit about the inner workings of CMake and found an unrelated bug in FindSFML.cmake...

(0037456)
Brad King (manager)
2014-12-15 09:08

Re 0015301:0037455: Okay, thanks for reporting back.
(0038696)
Robert Maynard (manager)
2015-05-04 09:05

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-12-12 12:03 jackcmedia New Issue
2014-12-12 13:22 Brad King Note Added: 0037448
2014-12-13 09:15 jackcmedia Note Added: 0037449
2014-12-13 09:16 jackcmedia Tag Attached: c++
2014-12-13 09:16 jackcmedia Tag Attached: CMake
2014-12-13 09:16 jackcmedia Tag Attached: find_library
2014-12-13 09:16 jackcmedia Tag Attached: unix
2014-12-13 09:16 jackcmedia Tag Attached: Windows 7
2014-12-14 09:17 jackcmedia Note Added: 0037455
2014-12-14 09:18 jackcmedia Note Edited: 0037455
2014-12-15 09:08 Brad King Note Added: 0037456
2014-12-15 09:08 Brad King Status new => resolved
2014-12-15 09:08 Brad King Resolution open => no change required
2015-05-04 09:05 Robert Maynard Note Added: 0038696
2015-05-04 09:05 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team