[cmake-developers] CMAKE_CURRENT_SOURCE_DIR points to build dir at build time
Brad King
brad.king at kitware.com
Fri May 15 11:09:18 EDT 2015
On 05/15/2015 05:09 AM, Paul Cercueil wrote:
> set(CS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/MyLib.cs
> ${CMAKE_CURRENT_SOURCE_DIR}/AssemblyInfo.cs)
> add_custom_command(OUTPUT mylib.dll
> COMMAND mcs /target:library /out:mylib.dll /debug /keyfile:${CMAKE_CURRENT_SOURCE_DIR}/key.snk ${CS_SOURCES})
>
> Under Windows, it will generate fine but Visual Studio will fail to
> build, stating that the "C:\build\Mylib.cs" and
> "C:\build\AssemblyInfo.cs" files cannot be found (source dir is
> "C:\src"). This indicates that it is in fact trying to find those files
> in the build directory, instead of the source directory.
CMake does not run during the build and there is no notion of
evaluating CMake variables during the build. The references
in your example code will be expanded during configuration
and the value should be generated into the .vcxproj file
without any such variable reference.
Take a look at the generated .vcxproj file. How does the
custom command appear there?
-Brad
More information about the cmake-developers
mailing list