MantisBT - CMake
View Issue Details
0012918CMakeCMakepublic2012-01-30 00:532012-07-09 06:52
TTAN 
Brad King 
highmajoralways
closedno change required 
Windows 7
CMake 2.8.7 
 
0012918: CMake wrongly generates x64 VC10 project files when Boost default stage folder is used for x32
I've got two builds of boost libraries for x32 and x64, being staged into \stage and \vc10x64_stage respectively.

with this command for the attached CMakeLists.txt below:
cmake ../.. -G"Visual Studio 10 Win64"
it correctly find the \vc10x64_stage folder, e.g.:

-- Check for working C compiler using: Visual Studio 10 Win64
-- Check for working C compiler using: Visual Studio 10 Win64 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10 Win64
-- Check for working CXX compiler using: Visual Studio 10 Win64 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Using 64bit compiler
-- Using 64bit Boost libs at X:/ttan/open-source/boost/trunk/vc10x64_stage/lib for host&machine exes
-- Boost version: 1.49.0
-- Found the following Boost libraries:
-- system
-- date_time
-- thread
-- Using 64bit Boost libs at X:/ttan/open-source/boost/trunk/vc10x64_stage/lib for test executables
-- Using 64bit Boost libs at X:/ttan/open-source/boost/trunk/vc10x64_stage/lib for pyhostlink lib
-- Boost version: 1.49.0
-- Found the following Boost libraries:
-- system
-- date_time
-- thread
-- python
-- Found PythonLibs: C:/Python27/libs/python27.lib
-- Configuring done
-- Generating done
-- Build files have been written to: D:/H/src/build

but fails to write into element <AdditionalDependencies> in the .vcxproj files, which actually refer to the libs under /stage.

Renaming /stage to something else solves the problem


- get a copy of boost library
- get it built and staged into folder /stage with VC10 x32, (to save time just pick one libray, say filesystem)
- get it built and staged into folder /vc10x64_stage with VC10 x64, (to save time just pick one libray, say filesystem)
- modify the attached CMakelists.txt to point to teh boost folder
- run cmake -G"Visual Studio 10 Win64" under VC10 x64 command Prompt console
- check the <AdditionalDependencies> tags in the generated vcxproj file, where
 the boost.system lib file is wrongly set to the one in /stage not /vc10x64_stage



 
CMakelists.txt for test:

set(bitness 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  set(bitness 64)
endif()

# compiler options
if(CMAKE_COMPILER_IS_GNUCXX)
  #add_definitions(-std=gnu++0x -time -o2 -wall -w -wshadow -wpointer-arith -wcast-qual -winline -werror)
  add_definitions(-std=gnu++0x -time -O2 -DBOOST_LIB_DIAGNOSTIC)
  #add_definitions(-std=gnu++0x -shared -O2 -o pyhostlink.so pyhostlink.cpp -lboost_python -I/usr/include/python2.7)
endif()
if(MSVC)
    #add_definitions(/EHsc /O2 /bigobj /Bt /MP1 /wd4003 /DBOOST_LIB_DIAGNOSTIC)
    add_definitions(/EHsc /O2 /bigobj /Bt /MP1 /wd4003 /DBOOST_LIB_DIAGNOSTIC /DBOOST_PYTHON_STATIC_LIB)
endif()

# finding boost
if(WIN32) # Operating System = Windows, including Cygwin
    set(my_boost_root "X:/ttan/open-source/boost/trunk")
    set(BOOST_ROOT ${my_boost_root})
    
    # visual C++
    if(MSVC)
        # lib for vc++ x32
        if(bitness EQUAL 32)
            set(my_stage_root stage)
        endif()
        
        # lib for vc++ x64
        if(bitness EQUAL 64)
            set(my_stage_root vc10x64_stage)
        endif()
    endif(MSVC)
    
    # compiler is a variant of g++
    if(MINGW)
        # lib for gcc x32
        if(bitness EQUAL 32)
            set(my_stage_root gcc_stage)
        endif()
        
        # lib for gcc x64
        if(bitness EQUAL 64)
            set(my_stage_root gccx64_stage)
        endif()
    endif(MINGW)

    set(Boost_LIBRARY_DIR "${my_boost_root}/${my_stage_root}/lib")
    message(STATUS "Using ${bitness}bit Boost libs at ${Boost_LIBRARY_DIR} for pyhostlink lib")
endif(WIN32)

if(UNIX) # Operating System = all UNIX-like OS's, including Apple OS X and Cygwin.
  set(Boost_INCLUDE_DIR /usr/local/include)
  set(Boost_LIBRARY_DIR /usr/local/lib)
  #set(Boost_ADDITIONAL_VERSIONS "1.48" "1.48.0")

  find_package(Threads) #for pthread
endif(UNIX)

# setting Boost usage
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS system date_time thread python REQUIRED)

# seeting python usage
find_package(PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
link_directories(${PYTHON_LIBRARIES})

if(Boost_FOUND)
  # setup boost dependencies
  include_directories(${Boost_INCLUDE_DIR})
  link_directories(${Boost_LIBRARY_DIR})

  set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)

  # build machine
  set(MACHINE_SRC_LIST pyhostlink.cpp)
  set(hostlink_lib_name pyhostlink)
  add_library(${hostlink_lib_name} SHARED ${MACHINE_SRC_LIST})
  set_target_properties(${hostlink_lib_name} PROPERTIES PREFIX "")
  if(MSVC)
   set_target_properties(${hostlink_lib_name} PROPERTIES OUTPUT_NAME "${hostlink_lib_name}.pyd")
  endif(MSVC)
  target_link_libraries(${hostlink_lib_name} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
  #install(TARGETS ${machine_exe_name} ${host_exe_name}
  # RUNTIME DESTINATION bin
  # LIBRARY DESTINATION lib
  # ARCHIVE DESTINATION lib
  #)
endif()

2010, boost, CMake, msvc10, vs2010
Issue History
2012-01-30 00:53TTANNew Issue
2012-01-30 00:55TTANTag Attached: 2010
2012-01-30 00:55TTANTag Attached: boost
2012-01-30 00:55TTANTag Attached: CMake
2012-01-30 00:55TTANTag Attached: msvc10
2012-01-30 00:55TTANTag Attached: vs2010
2012-01-30 09:00Brad KingNote Added: 0028421
2012-01-30 09:00Brad KingStatusnew => feedback
2012-01-30 21:18TTANNote Added: 0028427
2012-01-30 21:18TTANStatusfeedback => new
2012-01-31 10:15Brad KingNote Added: 0028432
2012-02-01 00:31TTANNote Added: 0028434
2012-02-01 08:00Brad KingStatusnew => resolved
2012-02-01 08:00Brad KingResolutionopen => no change required
2012-02-01 08:00Brad KingAssigned To => Brad King
2012-07-09 06:52David ColeNote Added: 0029962
2012-07-09 06:52David ColeStatusresolved => closed

Notes
(0028421)
Brad King   
2012-01-30 09:00   
The steps to reproduce are far too complicated for a bug report. The problem is either in the Boost code or can be reproduced in a much simpler test case.

I suggest bringing this up on the Boost.CMake list first:

 http://lists.boost.org/mailman/listinfo.cgi/boost-cmake [^]

and if it cannot be resolved there then on the normal CMake users list:

 http://www.cmake.org/mailman/listinfo/cmake [^]

If it can be shown to be a bug in CMake and not their code then post the simple test case back here.
(0028427)
TTAN   
2012-01-30 21:18   
Sorry if it sounds complicated in the previous report. I'll be trying to wrap it again.

I am using VC10 x64 command line to run this command:
cmake ../.. -G"Visual Studio 10 Win64"
In the CMakeLists file, I use
set(Boost_LIBRARY_DIR "vc10x64_stage/lib")
message(STATUS "Using ${bitness}bit Boost libs at ${Boost_LIBRARY_DIR} for pyhostlink lib")
the above 2 lines correcly print out the path.

However, in the generated .vcxproj file it actually locates libs in
"stage/lib", which happens to exist under the same dir as "vc10x64_stage/lib". And this error happens to the <AdditionalDependencies> element

Removing or Renaming "stage/lib" to something else("dftgrstage/lib") sovles the problem.
(0028432)
Brad King   
2012-01-31 10:15   
Your example sets Boost_LIBRARY_DIR which is not documented by FindBoost at all. It documents that Boost_LIBRARY_DIRS is an *output* variable. It also documents that you can set BOOST_LIBRARYDIR as an *input* value to tell the module which libraries to use. Change your example:

- set(Boost_LIBRARY_DIR "${my_boost_root}/${my_stage_root}/lib")
+ set(BOOST_LIBRARYDIR "${my_boost_root}/${my_stage_root}/lib")
(0028434)
TTAN   
2012-02-01 00:31   
thanks for the quick response. Nice to learn this trick.
(0029962)
David Cole   
2012-07-09 06:52   
Closing resolved issues that have not been updated in more than 4 months.