Je suis en train de développer un projet qui utilise des bibliothèques compilées boost. Je veux faire de la régression sur Bamboo. Mon idée était d'utiliser boost de mes chemins de système quand je construis sur mon pc, et un libboost_program_options.lib copié en construisant sur le bambou. Je copie les en-têtes boost et libboost_program_options pour qu'ils se trouvent dans le dossier CMAKE_SOURCE_DIR/boost. La bibliothèque a été compilée avec --layout = system, le nom de fichier est donc libboost_program_options.lib.Cmake recherche de boost lib par nom complet au lieu d'explicitement dit court
Voici comment mon CMake ressemble
cmake_minimum_required (VERSION 3.4)
project (Project)
file(GLOB SOURCES src/*.cpp)
set (SOURCE_FILES main.cpp other.cpp)
if (WIN32)
set (SOURCE_FILES ${SOURCE_FILES} many_other_windows.cpp)
endif (WIN32)
if (UNIX)
set (SOURCE_FILES ${SOURCE_FILES} many_other_unix.cpp)
endif (UNIX)
set(Boost_USE_STATIC_LIBS ON)
# This is a hint for find_package to look for boost libs/includes in this dirs but it doesnt work
set(BOOST_INCLUDEDIR ${CMAKE_SOURCE_DIR}/boost)
set(BOOST_LIBRARYDIR ${CMAKE_SOURCE_DIR}/boost)
find_package(Boost 1.63.0 COMPONENTS program_options)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set(TARGET_LINK_LIBRARIES ${Boost_LIBRARIES})
else()
include_directories(${CMAKE_SOURCE_DIR})
link_directories(${CMAKE_SOURCE_DIR}/boost)
if (WIN32)
set(TARGET_LINK_LIBRARIES libboost_program_options)
endif (WIN32)
if (UNIX)
set(TARGET_LINK_LIBRARIES libboost_program_options.a)
endif (UNIX)
endif()
add_executable (Project ${SOURCE_FILES})
if (WIN32)
set(TARGET_LINK_LIBRARIES ${TARGET_LINK_LIBRARIES} shlwapi)
endif (WIN32)
target_link_libraries(Project ${TARGET_LINK_LIBRARIES})
partie du fichier de projet Visual Studio
chemin de type/de project.vcxproj:
(...)
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;libboost_program_options.lib;shlwapi.lib</AdditionalDependencies>
(...)
Et l'invocation de linker
04-Apr-2017 17:58:28 D:\MIDDLEWARE\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:"D:\bamboo-home\xml-data\build-dir\AS-CA-W64\Project\bin\Release\Project.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"D:/bamboo-home/xml-data/build-dir/AS-CA-W64/PostCompilator/boost" /LIBPATH:"D:/bamboo-home/xml-data/build-dir/AS-CA-W64/PostCompilator/boost/Release" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib libboost_program_options.lib shlwapi.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"D:/bamboo-home/xml-data/build-dir/AS-CA-W64/Project/bin/Release/Project.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:/bamboo-home/xml-data/build-dir/AS-CA-W64/PostCompilator/bin/Release/Project.lib" /MACHINE:X64 /machine:x64 Project.dir\Release\main.obj
04-Apr-2017 17:58:28 LINK : fatal error LNK1104: cannot open file 'libboost_program_options-vc140-mt-1_64.lib' [D:\bamboo-home\xml-data\build-dir\AS-CA-W64\Project\build\Project\Project.vcxproj]
04-Apr-2017 17:58:28 Done Building Project "D:\bamboo-home\xml-data\build-dir\AS-CA-W64\Project\build\Project\Project.vcxproj" (default targets) -- FAILED.
Notez comment dans cmake le nom court a changé pour un nom complet avec le nom et la version du compilateur.
Quelqu'un sait comment faire pour trouver cmake cette bibliothèque? Quelqu'un at-il une suggestion comment je peux le faire mieux pour rendre mon projet constructible sur mon pc avec boost dans les chemins du système comme sur le bambou où je veux copier la lib? Peut-être que quelqu'un a une meilleure idée de comment intégrer coup de pouce dans mon projet sur le bambou
Meilleures salutations
Est-il possible que vous obteniez le nom de bibliothèque program_options utilisé précédemment mis en cache par CMAKE et il réutilise juste cela? – diverscuba23
Je fais de la force pour construire mon propre repo, donc tout devrait être enlevé avant la prochaine génération. Il exécute également link.exe avec le nom court ainsi je ne pense pas ainsi. Je ne suis pas très habile avec cmake tho –
On dirait que le fichier 'libboost_program_options.lib' fait référence à' libboost_program_options-vc140-mt-1_64.lib' d'une manière ou d'une autre. Ce n'est certainement pas un CMake qui * transforme * le premier nom de fichier en second. – Tsyvarev