[CMake] Paths with spaces - Visual Studio

David Cole david.cole at kitware.com
Thu Jul 5 06:26:06 EDT 2012


On Wed, Jul 4, 2012 at 3:20 PM, Totte Karlsson <totte at dunescientific.com> wrote:
> On 7/4/2012 12:01 PM, David Cole wrote:
>>
>> The preferred way is simply to add the def file as a source file of
>> your library or executable:
>>
>>    add_library(my lib SHARED
>>      ${cxx_sources}
>>      ${CMAKE_CURRENT_SOURCE_DIR}/c_api_vs.def
>>      )
>
> That makes sense. I'm using different def file for different compilers, but
> I guess one can 'construct' a file name before adding to add_library.
>
> Is the spaces problem  present for all flags and 'options' to cmake
> functions?
>
> tk
>
>
>> Then you don't need to modify the linker flags at all.
>>
>>
>> HTH,
>> David
>>
>>
>> On Wed, Jul 4, 2012 at 1:03 PM, Totte Karlsson <totte at dunescientific.com>
>> wrote:
>>>
>>> Hi,
>>> I had a problem with a source path containing spaces:
>>> SET (CMAKE_SHARED_LINKER_FLAGS  "${CMAKE_SHARED_LINKER_FLAGS}
>>> /DEF:${CMAKE_CURRENT_SOURCE_DIR}/c_api_vs.def")
>>>
>>> where CMAKE_CURRENT_SOURCE_DIR had spaces. That casued problems in the
>>> visual studio project.
>>>
>>> I quoted the above as this:
>>> ..... \"/DEF:${CMAKE_CURRENT_SOURCE_DIR}/c_api_vs.def\"")
>>>
>>> and it 'fixed' it. Question is. Is that the preferred way?
>>>
>>> thanks,
>>> Totte
>>>
>>>
>>> --
>>> .........................
>>> Totte Karlsson, Ph.D.
>>> Dune Scientific, LLC
>>> 425-296 1980 (office)
>>> 425-780 9648 (cell)
>>> www.dunescientific.com
>>> .........................
>>>
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

CMake works with spaces in directory names and file names, but in some
places, quotes or escaping is required.

On the vast majority of our nightly dashboard submissions, both the
source tree and the build tree have a space in the path name.

So: in general, CMake handles spaces in filenames, as long as all the
underlying build tools also handle them.

If you run into a specific problem, the best thing to do is to ask on
the mailing list here, just like you did.


Thanks,
David


More information about the CMake mailing list