[CMake] $ is not empty even if configuration has no PDB

2018-08-03 Thread Louis-Paul CORDIER

Hi everybody,

I am currently trying to add reproducible MSVC build to my project using 
ducible tool.


ducible can take in optional parameter, a pdb file.

I am using the following command:

  set(DUCIBLE_BINARY "${CMAKE_CURRENT_LIST_DIR}/bin/ducible.exe")
  add_custom_command(TARGET ${MYTARGET}
 POST_BUILD
 COMMAND ${DUCIBLE_BINARY} 
\"$\" \"$\"

 COMMENT "Patching for reproducible build.")

However even if the current configuration is not generating a PDB (for 
Release for instance), this generator expression is providing a path, 
making the ducible tool to fail because the pdb file does not exists. Is 
it a bug? How can I detect using generator expression if a file exists? 
I tried to check all _PDB_ properties of the target but they are all 
empty by default.


Thank you very much for your help,

Louis-Paul CORDIER
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] DLL handling under CMake

2017-07-17 Thread Louis-Paul CORDIER

Hi,

I bump this question again for DLL library handling. Still I have the 
issue with my dependency "scanner" in my previous email that can't 
evaluate if a target with a generator expression is a valid one or not.


if(NOT TARGET "$<$:Foo_lib>")
  # will never go into this statement
endif()

Thanks,

LP

Le 04/07/2017 à 10:19, Louis-Paul CORDIER a écrit :


Hi,

Thank you very much for this code snippet. However I don't like the 
fixup_bundle function, as it takes the first dll that it found to be 
linked against.


I also did a try with a dependency scanning function. It is quiet long 
to write, but I guess it is the cleanest way to handle DLL under Windows.
Note: I still have an issue with this function. Indeed, if user uses 
Generator expressions for library dependencies, it will not work.

e.g:
add_library(Foo_lib IMPORTED GLOBAL)
# ... set location properties
target_link_libraries(${PROJECT_NAME} optimized 
$<$:Foo_lib>)


Any idea for a workaround? What do you think about this CMake code?

Also, I would see a real benefit to add a LINK_DEPENDENT_LIBRARIES 
property (inspired of IMPORTED_LINK_DEPENDENT_LIBRARIES) to each 
target that could be automatically filled by each 
target_link_libraries() calls.




# This function scan all dependencies of a project recursively, and 
retrieve all shared

# library associated with it.
# Prerequisite: your upstream CMakeLists.txt must make use of 
add_library(foo SHARED IMPORTED GLOBAL),

# and fill the following properties on the imported target:
# set_target_properties(foo PROPERTIES IMPORTED_IMPLIB "path_to_foo.lib")
# set_target_properties(foo PROPERTIES IMPORTED_LOCATION 
"path_to_foo.dll")
# set_target_properties(foo PROPERTIES 
IMPORTED_LINK_DEPENDENT_LIBRARIES "path_to_dll_on_which_foo_depends.dll")
# GLOBAL keyword is important as it allows downstream CMakeLists.txt 
to scan dependencies.


# Input parameters:
# dep_to_scan: your downstream project
# config_to_scan: configuration to use for the scanning.
# output_variable: variable in which the function stores the result.

# Usage:
# RECURSIVE_SCAN(my_app Release DLLS)
#  install(FILES ${DLLS}
# DESTINATION release
# CONFIGURATIONS Release)

set(COUNT 0)
function(RECURSIVE_SCAN dep_to_scan config_to_scan output_variable)

  MATH(EXPR COUNT "${COUNT}+1")
  string(RANDOM LENGTH ${COUNT} ALPHABET "-" SPACES)

  message("${SPACES} Scanning ${dep_to_scan}")
  if(NOT TARGET ${dep_to_scan})
MATH(EXPR COUNT "${COUNT}-1")
#message("${dep_to_scan} Is not target")
return()
  endif()


  get_target_property(_is_imported ${dep_to_scan} IMPORTED)
  if(_is_imported)

# We need to check if the imported library rely on other shared 
libraries.
get_target_property(_dependent_dll ${_lib} 
IMPORTED_LINK_DEPENDENT_LIBRARIES_${config_to_scan})

if(NOT _dependent_dll)
  get_target_property(_dependent_dll ${_lib} 
IMPORTED_LINK_DEPENDENT_LIBRARIES)

endif()

if(_dependent_dll)
  list(APPEND ${output_variable} ${_dependent_dll})
endif()


#Otherwise, check if it is a shared library. (LOCATION variable 
can be

# either .lib or DLL regarding of the type of library.)
get_target_property(_TYPE ${dep_to_scan} TYPE)

if(NOT _TYPE STREQUAL STATIC_LIBRARY)
  get_target_property(_dll_found ${dep_to_scan} 
LOCATION_${config_to_scan})

  if(_dll_found)
list(APPEND ${output_variable} ${_dll_found})
  endif()

endif()

message("${SPACES}- DLL found: (${${output_variable}})")

  endif(_is_imported)

  get_target_property(_libraries ${dep_to_scan} INTERFACE_LINK_LIBRARIES)

  if(_libraries)
  foreach(_lib ${_libraries})
RECURSIVE_SCAN(${_lib} ${config_to_scan} ${output_variable})
  endforeach()
  endif()

  # If we reach our first recursion, we need to clean the list of
  # DLL in order to remove duplicates.
  MATH(EXPR COUNT "${COUNT}-1")

  if(${COUNT} EQUAL 0)
list(REMOVE_DUPLICATES ${output_variable})
  endif()

  set(${output_variable} ${${output_variable}} PARENT_SCOPE)

endfunction(RECURSIVE_SCAN)


Best regards,

Louis-Paul CORDIER

Le 04/05/2017 à 09:51, lec...@gmail.com a écrit :


I managed to get it working by using an intermediate script.

One might want to generate the script instead of using the « RUN_IT » 
variable trick.


This was only tested on Windows, but seems to work fine.

Put the following code in a xx.cmake file, include it from your 
CMakeLists.txt and enjoy.


# This is a helper script to run BundleUtilities fixup_bundle as 
postbuild


# for a target. The primary use case is to copy .DLLs to the build 
directory for


# the Windows platform. It allows generator expressions to be used to 
determine


# the binary location

#

# Usage : run_fixup(TARGET LIBS DIRS)

# - TARGET : A cmake target

# - See fixup_bundle for LIBS and DIRS arguments

if(RUN_IT)

Re: [CMake] DLL handling under CMake

2017-07-04 Thread Louis-Paul CORDIER

Hi,

Thank you very much for this code snippet. However I don't like the 
fixup_bundle function, as it takes the first dll that it found to be 
linked against.


I also did a try with a dependency scanning function. It is quiet long 
to write, but I guess it is the cleanest way to handle DLL under Windows.
Note: I still have an issue with this function. Indeed, if user uses 
Generator expressions for library dependencies, it will not work.

e.g:
add_library(Foo_lib IMPORTED GLOBAL)
# ... set location properties
target_link_libraries(${PROJECT_NAME} optimized 
$<$:Foo_lib>)


Any idea for a workaround? What do you think about this CMake code?

Also, I would see a real benefit to add a LINK_DEPENDENT_LIBRARIES 
property (inspired of IMPORTED_LINK_DEPENDENT_LIBRARIES) to each target 
that could be automatically filled by each target_link_libraries() calls.




# This function scan all dependencies of a project recursively, and 
retrieve all shared

# library associated with it.
# Prerequisite: your upstream CMakeLists.txt must make use of 
add_library(foo SHARED IMPORTED GLOBAL),

# and fill the following properties on the imported target:
# set_target_properties(foo PROPERTIES IMPORTED_IMPLIB "path_to_foo.lib")
# set_target_properties(foo PROPERTIES IMPORTED_LOCATION "path_to_foo.dll")
# set_target_properties(foo PROPERTIES IMPORTED_LINK_DEPENDENT_LIBRARIES 
"path_to_dll_on_which_foo_depends.dll")
# GLOBAL keyword is important as it allows downstream CMakeLists.txt to 
scan dependencies.


# Input parameters:
# dep_to_scan: your downstream project
# config_to_scan: configuration to use for the scanning.
# output_variable: variable in which the function stores the result.

# Usage:
# RECURSIVE_SCAN(my_app Release DLLS)
#  install(FILES ${DLLS}
# DESTINATION release
# CONFIGURATIONS Release)

set(COUNT 0)
function(RECURSIVE_SCAN dep_to_scan config_to_scan output_variable)

  MATH(EXPR COUNT "${COUNT}+1")
  string(RANDOM LENGTH ${COUNT} ALPHABET "-" SPACES)

  message("${SPACES} Scanning ${dep_to_scan}")
  if(NOT TARGET ${dep_to_scan})
MATH(EXPR COUNT "${COUNT}-1")
#message("${dep_to_scan} Is not target")
return()
  endif()


  get_target_property(_is_imported ${dep_to_scan} IMPORTED)
  if(_is_imported)

# We need to check if the imported library rely on other shared 
libraries.
get_target_property(_dependent_dll ${_lib} 
IMPORTED_LINK_DEPENDENT_LIBRARIES_${config_to_scan})

if(NOT _dependent_dll)
  get_target_property(_dependent_dll ${_lib} 
IMPORTED_LINK_DEPENDENT_LIBRARIES)

endif()

if(_dependent_dll)
  list(APPEND ${output_variable} ${_dependent_dll})
endif()


#Otherwise, check if it is a shared library. (LOCATION variable can be
# either .lib or DLL regarding of the type of library.)
get_target_property(_TYPE ${dep_to_scan} TYPE)

if(NOT _TYPE STREQUAL STATIC_LIBRARY)
  get_target_property(_dll_found ${dep_to_scan} 
LOCATION_${config_to_scan})

  if(_dll_found)
list(APPEND ${output_variable} ${_dll_found})
  endif()

endif()

message("${SPACES}- DLL found: (${${output_variable}})")

  endif(_is_imported)

  get_target_property(_libraries ${dep_to_scan} INTERFACE_LINK_LIBRARIES)

  if(_libraries)
  foreach(_lib ${_libraries})
RECURSIVE_SCAN(${_lib} ${config_to_scan} ${output_variable})
  endforeach()
  endif()

  # If we reach our first recursion, we need to clean the list of
  # DLL in order to remove duplicates.
  MATH(EXPR COUNT "${COUNT}-1")

  if(${COUNT} EQUAL 0)
list(REMOVE_DUPLICATES ${output_variable})
  endif()

  set(${output_variable} ${${output_variable}} PARENT_SCOPE)

endfunction(RECURSIVE_SCAN)


Best regards,

Louis-Paul CORDIER

Le 04/05/2017 à 09:51, lec...@gmail.com a écrit :


I managed to get it working by using an intermediate script.

One might want to generate the script instead of using the « RUN_IT » 
variable trick.


This was only tested on Windows, but seems to work fine.

Put the following code in a xx.cmake file, include it from your 
CMakeLists.txt and enjoy.


# This is a helper script to run BundleUtilities fixup_bundle as postbuild

# for a target. The primary use case is to copy .DLLs to the build 
directory for


# the Windows platform. It allows generator expressions to be used to 
determine


# the binary location

#

# Usage : run_fixup(TARGET LIBS DIRS)

# - TARGET : A cmake target

# - See fixup_bundle for LIBS and DIRS arguments

if(RUN_IT)

# Script ran by the add_custom_command

include(BundleUtilities)

fixup_bundle("${TO_FIXUP_FILE}" "${TO_FIXUP_LIBS}" "${TO_FIXUP_DIRS}")

# End of script ran by the add_custom_command

else()

set(THIS_FILE ${CMAKE_CURRENT_LIST_FILE})

message(${THIS_FILE})

function(run_fixup _target _libs _dirs)

message(${THIS_FILE})


Re: [CMake] find_package(), FindXXX.cmake and IMPORTED add_library()

2017-07-03 Thread Louis-Paul CORDIER

(My answers to your previous email are below this new question.)

I have another question thus: some libraries, especially on Windows, 
provide both static and shared library. Is there any way for selecting 
which kind of library we want to get?

For instance:

LibJPEGTurbo has (turbojpeg.lib + turbojpeg.dll) and 
(turbojpeg-static.lib). So in the find_package, we can do


1. shared version
add_library(LibJPEGTurbo SHARED IMPORTED)
set_target_properties(LibJPEGTurbo PROPERTIES IMPORTED_IMPLIB 
"turbojpeg.lib")
set_target_properties(LibJPEGTurbo PROPERTIES IMPORTED_LOCATION 
"turbojpeg.dll")


2. static version
add_library(LibJPEGTurbo STATIC IMPORTED)
set_target_properties(LibJPEGTurbo PROPERTIES IMPORTED_LOCATION 
"turbojpeg-static.lib")


Maybe setting a variable before calling find_package, like 
set(FIND_SHAREDLIBS TRUE)?



Le 01/07/2017 à 15:47, P F a écrit :

On Jun 30, 2017, at 6:40 AM, Louis-Paul CORDIER <lp.cord...@dynamixyz.com> 
wrote:

Hi,

I'm particularly familiar with find_package() command, add_library(... 
IMPORTED) and find_library(). However, I found there are many differences on 
find_package() usage depending of the library being imported.

For instance, using find_package() on Qt5 will retrieve a bunch of 
*Config.cmake files in the Qt installation tree, and add each components as a 
library using add_library(Qt5::COMPONENT SHARED IMPORTED).
One nice feature with that is the possibility to retrieve the LOCATION property 
on each component to get the DLL file.

That said when using find_package(sharedLibFOO) that will make use of 
hand-written FindsharedLibFOO.cmake, some variables like FindsharedLib_FOUND, 
FindsharedLib_LIBRARIES, FindsharedLib_VERSION (etc.) are set by the script, 
but there is almost never add_library() command used inside this CMake find 
script.

1. Should it be mandatory to use add_library() in FindXXX.cmake scripts, so the 
user just needs to target_link_libraries() and all compile definitions, 
includes dir, and lib dir are automatically imported?

This probably should be the case, but I think a lack of contributions is the 
problem with the current Find modules not being update on each module.


Thanks, this should be added to the documentation of FindPackage then so 
people can start getting good habits, shouldn't be?
I guess of your answer that every find_package() should populate 
LOCATION_ properties.





2. If not, is it a good practice to use add_library() when writing our 
FindXXX.cmake package?

When writing your own FindXXX.cmake, you should first report a bug to library 
XXX for not supporting cmake downstream. Also, the purpose of `find_package` is 
to find prebuilt binaries, its not to add new libraries to be built.
Unfortunately, many people using CMake build system don't know how to 
write a proper CMakeLists.txt as there are plenty ways to workaround the 
exporting process of CMake. Also many project are not using CMake at all.
When I mean the add_library command, I am talking about the IMPORTED 
function of it, meaning that the library is already built and shouldn't 
create a new target in the Makefile/IDE.

3. When making an application, is it a good practice to create an imported 
target for each library, instead of appending manually to the current project 
using target_link_libraries(), target_compile_definitions(), 
target_include_directories() and so on?

Yes, it is good practice to make your dependencies imported targets as it 
allows for the dependencies to be relocatable.

Here is some more information about cmake packages:

https://cmake.org/cmake/help/v3.7/manual/cmake-packages.7.html




--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] find_package(), FindXXX.cmake and IMPORTED add_library()

2017-06-30 Thread Louis-Paul CORDIER

Hi,

I'm particularly familiar with find_package() command, add_library(... 
IMPORTED) and find_library(). However, I found there are many 
differences on find_package() usage depending of the library being imported.


For instance, using find_package() on Qt5 will retrieve a bunch of 
*Config.cmake files in the Qt installation tree, and add each components 
as a library using add_library(Qt5::COMPONENT SHARED IMPORTED).
One nice feature with that is the possibility to retrieve the LOCATION 
property on each component to get the DLL file.


That said when using find_package(sharedLibFOO) that will make use of 
hand-written FindsharedLibFOO.cmake, some variables like 
FindsharedLib_FOUND, FindsharedLib_LIBRARIES, FindsharedLib_VERSION 
(etc.) are set by the script, but there is almost never add_library() 
command used inside this CMake find script.


1. Should it be mandatory to use add_library() in FindXXX.cmake scripts, 
so the user just needs to target_link_libraries() and all compile 
definitions, includes dir, and lib dir are automatically imported?
2. If not, is it a good practice to use add_library() when writing our 
FindXXX.cmake package?
3. When making an application, is it a good practice to create an 
imported target for each library, instead of appending manually to the 
current project using target_link_libraries(), 
target_compile_definitions(), target_include_directories() and so on?


Thank you for your lights,
BR

Louis-Paul CORDIER
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


[CMake] DLL handling under CMake

2017-04-28 Thread Louis-Paul CORDIER

Hi,

I'm using CMake for a while now for cross-platform project.

In opposition to Linux, Windows does not have a library system 
management through a repository system. I would say that 99% of 
applications that have common libraries between them does not share the 
runtimes. Each time, the .dll files are duplicated for each application. 
We have to live with that, and to create proper CMakeLists.txt that can 
handle DLL integration.


I think many of CMake users have the following pipeline on Windows:

1. Run CMake (this will execute some find_library to get the correct 
.lib files)

2. Compile the application
3. Run the INSTALL target
4. Copy the .dll files into the output binary folder.
5. Package the application with the DLL inside (e.g innosetup)

Currently find_library does not search for runtime, but only for .lib. 
So even if a developer is using find_library, he/she has to implement 
some additional CMake code to retrieve the path to .dll files and copy 
them using the install or the file CMake commands. I added my current 
code for handling Qt library in my project at the end of this email. (I 
put a huge part of it if someone want to reuse it). You will notice that 
this code is handling the case where you are debugging using Visual 
Studio, to avoid the missing .DLL issue.


This steps are tedious and I'm wondering if there is a mechanism that 
exists or that have to be imagined to make the DLL nightmare end.


All the best

Louis-Paul Cordier


...

#Folder where compiled files for release/debug install will be placed
set(G3_RELEASE_DIR  "release")
set(G3_DEBUG_DIR "debug")

find_package(Qt5 ${QT5VC2015_VERSION} EXACT COMPONENTS Core OpenGL 
Concurrent REQUIRED)


QT5_WRAP_UI(...)
QT5_WRAP_CPP(...)
target_include_directories(...)
target_compile_definitions(...)

#Add Qt libraries to the linker
target_link_libraries(${PROJECT_NAME}
  ${Qt5Widgets_LIBRARIES}
  ${Qt5OpenGL_LIBRARIES}
  ${Qt5Concurrent_LIBRARIES}
  )

if( WIN32 )
  SET(QT_DLL
  Qt5Core
  Qt5Gui
  Qt5Widgets
  Qt5OpenGL
  Qt5Concurrent
  )

foreach( _file ${QT_DLL} )
  list( APPEND DLL_LIBRARIES  "${QT5_DIR}/bin/${_file}.dll" )
  list( APPEND DLL_LIBRARIES_D  "${QT5_DIR}/bin/${_file}d.dll" )
endforeach( _file ${QT_DLL} )

#TODO: add the platform libraries.

endif( WIN32 )

# I add other DLLs of other project's library by appending to 
DLL_LIBRARIES and DLL_LIBRARIES_D


#Handle DLLs under Windows.
if(WIN32)

  set(DLL_LIBRARIES_PATH "")
  set(DLL_LIBRARIES_D_PATH "")

  #Process Release libraries.
  foreach( _file ${DLL_LIBRARIES} )

# Convert path to CMake path to avoid escaping issues.
file(TO_CMAKE_PATH ${_file} _file_cmake_path)

#check file existance
if(NOT EXISTS ${_file_cmake_path})
  message(FATAL_ERROR "Missing dll file: ${_file_cmake_path}")
endif(NOT EXISTS ${_file_cmake_path})

# Add the DLL to the installation process.
install(FILES ${_file_cmake_path}
  DESTINATION ${G3_RELEASE_DIR}
  CONFIGURATIONS Release RelWithDebInfo MinSizeRel Release_CMT 
Release_Net)


# Extract the folder path of the DLL. It allows to add the folder 
where the
# DLLs are stored to the PATH environment of Visual Studio, in 
order to avoid

# copying DLL after each builds.
if(MSVC)
  get_filename_component(_dll_folder ${_file} DIRECTORY)
  list(APPEND DLL_LIBRARIES_PATH ${_dll_folder})
endif(MSVC)

  endforeach( _file ${DLL_LIBRARIES} )

  #Process Debug libraries.
  foreach( _file ${DLL_LIBRARIES_D} )

# Convert path to CMake path to avoid escaping issues.
file(TO_CMAKE_PATH ${_file} _file_cmake_path)

#check file existance
if(NOT EXISTS ${_file_cmake_path})
  message(FATAL_ERROR "Missing dll file: ${_file_cmake_path}")
endif(NOT EXISTS ${_file_cmake_path})

# Add the DLL to the installation process.
install(FILES ${_file_cmake_path}
  DESTINATION ${G3_DEBUG_DIR}
  CONFIGURATIONS Debug)

# Extract the folder path of the DLL. It allows to add the folder 
where the
# DLLs are stored to the PATH environment of Visual Studio, in 
order to avoid

# copying DLL after each builds.
if(MSVC)
  get_filename_component(_dll_folder ${_file} DIRECTORY)
  list(APPEND DLL_LIBRARIES_PATH_D ${_dll_folder})
endif(MSVC)

  endforeach( _file ${DLL_LIBRARIES_D} )

  if(MSVC)
#Remove duplicate entries
list(REMOVE_DUPLICATES DLL_LIBRARIES_PATH)
list(REMOVE_DUPLICATES DLL_LIBRARIES_PATH_D)

#Set architecture
if(ARCH_X64)
  set(DLL_LIBRARIES_ARCH "x64")
else(ARCH_X64)
  set(DLL_LIBRARIES_ARCH "Win32")
endif(ARCH_X64)

# The output file goes in the build dir.
# @ONLY means only variables of the form @VAR@ will be substituted.
# This method need DLL_LIBRARIES_ARCH, DLL_LIBRARIES_PATH and 
DLL_LIBRARIES_PATH_D
# variables to be set. DONT FORG

Re: [CMake] Windows mapped network drive and 'if EXISTS'

2017-03-03 Thread Louis-Paul CORDIER

Hi again,

Problem solved by rebooting Windows and the samba share.

Thank you anyway!

Le 03/03/2017 à 15:43, Louis-Paul CORDIER a écrit :

Does not solve the issue here...
I'm using the latest cmake release 3.7.2

Your Z is a mapped network drive, am I right?

This behaviour is causing find_package to fail as well.

Le 03/03/2017 à 15:23, Nils Gladitz a écrit :

On 03/03/2017 02:28 PM, Louis-Paul CORDIER wrote:



When I try to do a if(EXISTS "Z:\"), it never jump into the if 
statement.


Try if(EXISTS "Z:\\") or if(EXISTS "Z:/").
Either works for me.

if(EXISTS "Z:\") looks like it should have been a syntax error since 
the backslash starts an escape sequence [1].


Nils

[1] 
https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#escape-sequences








--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] Windows mapped network drive and 'if EXISTS'

2017-03-03 Thread Louis-Paul CORDIER

Does not solve the issue here...
I'm using the latest cmake release 3.7.2

Your Z is a mapped network drive, am I right?

This behaviour is causing find_package to fail as well.

Le 03/03/2017 à 15:23, Nils Gladitz a écrit :

On 03/03/2017 02:28 PM, Louis-Paul CORDIER wrote:



When I try to do a if(EXISTS "Z:\"), it never jump into the if 
statement.


Try if(EXISTS "Z:\\") or if(EXISTS "Z:/").
Either works for me.

if(EXISTS "Z:\") looks like it should have been a syntax error since 
the backslash starts an escape sequence [1].


Nils

[1] 
https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#escape-sequences






--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


[CMake] Windows mapped network drive and 'if EXISTS'

2017-03-03 Thread Louis-Paul CORDIER

Hi,

I'm trying to use the cmake 'if' statement with the EXISTS parameter, 
used for checking folder/file existence.


In my project, I have a library stored on a network samba folder. On my 
Windows dev platform, I mapped a network drive (Windows 7 -> Computer -> 
Map network drive) on this share (the created network letter is Z:). 
Other program can access and work on this drive without any problems.


When I try to do a if(EXISTS "Z:\"), it never jump into the if statement.

Is it a bug?

Best regards,

LPC

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


[CMake] Adding Cmake version in online documentation

2016-11-08 Thread Louis-Paul CORDIER

Hi,

This is a feature proposal for the documentation. Cmake is making use of 
cmake_minimum_required() command, that is very useful. Unfortunately it 
is very hard to identify commands that will work without browsing all 
version of cmake documentation for a given command.


That said, adding a "since version" number for a feature/command would 
be great, like cplusplus.com does (example here: 
http://www.cplusplus.com/reference/unordered_map/unordered_map/?kw=unordered_map)


For instance, the command

list(FILTER ...)

has been introduced in Cmake 3.6. Why not adding

list(FILTER ...) (since 3.6)

?
--

*Best Regards/
Louis-Paul CORDIER
*

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Re: [CMake] target_link_libraries and flags issue with Visual Studio

2016-08-22 Thread Louis-Paul CORDIER

Dear Guillaume,

Thank you for the suggestion. Unfortunately, it seems this option does 
not fill the linker property of the linking project.


Otherwise, it seems that STATIC_LIBRARY_FLAGS is adding the link 
properties to the 'librarian':


set_target_properties(lib_project PROPERTIES STATIC_LIBRARY_FLAGS 
"-level='requireAdministrator' -uiAccess='false'")


Any other suggestions? Thanks!

LP

Le 08/08/2016 à 02:45, Guillaume Dumont a écrit :

Hi,

You can use the LINK_FLAGS or LINK_FLAGS_ for this:

https://cmake.org/cmake/help/v3.6/prop_tgt/LINK_FLAGS.html

Have you tried that?

Guillaume

On Wed, Aug 3, 2016 at 7:02 AM, Louis-Paul CORDIER 
<lp.cord...@dynamixyz.com <mailto:lp.cord...@dynamixyz.com>> wrote:


ase not t





--
Guillaume Dumont
=
dumont.guilla...@gmail.com <mailto:dumont.guilla...@gmail.com>


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] target_link_libraries and flags issue with Visual Studio

2016-08-03 Thread Louis-Paul CORDIER
On the target_link_libraries() command documentation page, it is written 
that it is possible to pass flags to this function, if they start with a 
'-' character.
This functionnality seems to be broken with Visual Studio. Indeed flags 
in the Visual Studio linker are using slashes instead of dash.


For instance, trying to enable map file generation in the linkers is 
failing:


target_link_libraries(${PROJECT_NAME} -MAP)

Resulting output in the linker command line is "-MAP" (note the presence 
of quotes). It should be /MAP (without quotes) in order to be properly 
recognized by the linker command-line parser. After few researches, it 
seems that this issue is 
similar:http://public.kitware.com/pipermail/cmake/2015-June/060989.html 



Context:

I have a library called lib_project. I have an executable my_project 
that links against lib_project. When linking the final binary, I need to 
enable UAC support in order to force execution of the binary as 
administrator 
(http://stackoverflow.com/questions/1655089/cmake-requireadministrator). 
lib_project uses a Windows API that needs administrator level set in the 
final executable. So I would like to force my_project to set this 
specific flag, but I would like to see this set in the CmakeLists.txt of 
lib_project. Regarding the documentation, the following command should 
do the trick (but not working currently):


target_link_libraries(lib_project PUBLIC -level='requireAdministrator' 
-uiAccess='false')


Please not that the -level can bring bugs as it could be interpreted by 
Cmake as "link against 'evel' library".


Do I have pointed a new bug in the Visual Studio generator? Would a 
target_link_flags() command be a good idea to implement?


Best regards,

L-P

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake