I have a CMake project which generates a Visual Studio solution and its associated project files. I've noticed that there are a lot of "CustomBuild" rules generated in the projects which seem to re-run CMake if for some reason the projects are not up-to-date:
<ItemGroup>
<CustomBuild Include="foo\CMakeLists.txt">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building Custom Rule S:/foo/CMakeLists.txt</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">setlocal
"C:\...\cmake.exe" -HS:/foo -BS:/foo/msvc-10.0 --check-stamp-file S:\foo\msvc-10.0\CMakeFiles\generate.stamp
...
</CustomBuild>
</ItemGroup>
Is there a way to tell CMake to disable generating these custom build rules? My goal is to have CMake generate solution/project files without still being attached to CMake.
Thanks!
No, that can't be done.
Moreover, those rules are not only for re-generating project files if they're not up-to-date anymore. For instance, there's also the CMake command mode that provides portability for copying files, directories, md5 sums and many other nice things.
The bakefile project tried to do that (generating independent project files), but it seems it's pretty much dead now.
Related
The Visual Studio 2019 project, which was built via cmake displays
File Modification Detected
The project ABC has been modified outside the environment
Reload ... Ignore ...
message.
How can I prevent cmake from updating the VS config files, for the project or system wide?
In what section of the cmake build files this behavior is defined (so that I can rebuild the project without this feature)?
No, you cannot prevent this (afaik). Consider the scenario where you add a source file to a target in a CMakeLists.txt file. CMake needs to update the Visual Studio project files it generated which results in project file(s) being overwritten. CMake sets up the solution in a way to ensure such an update on a modification of the cmake files. Visual Studio reacts to the solution/project files being overwritten by displaying the dialog you mentioned.
In general you'll want to click "Reload" which should just update the projects according to the modification in the cmake sources. If for a command line build tool shows up though, you may want to select "Ignore" though, since sometimes the build output is deleted on a reload of projects/the solution and you'll probably want to check the error message.
If you're interested: Overriding the project files happens in the ZERO_CHECK target.
If the dialog is displayed on a build even if you did not modify the cmake files since the last build, you may want to check the console for a warning in the output of cmake though; this may indicate that there may be some issue in your cmake files...
I have a cross-platform project which uses CMake. I am doing out-of-source builds so basically I have a source directory "src" which contains the CMakeLists.txt and then I have a "src/build" directory where I generate the out-of-source build.
However when using Visual Studio (2013) it does not place the executable in the build dir but to "src/build/Debug" for example (depends on the selected configuration). I think this was referred as "$(OutDir)" inside VS. How do I refer to the (runtime) output directory in my CMakeLists.txt so I can copy DLLs and shaders where my executable is?
Edit: The suggested duplicate answer does not seem correct to me. In that answer you just force the output directories to be static which sounds wrong if you are using a multi-configuration build system like Visual Studio.
I solved my problem by copying the files with the "file (GENERATE OUTPUT)" which supports the cmake-generator-expressions suggested by StAlphonzo:
foreach (file ${SHADER_SOURCES})
file (GENERATE OUTPUT $<CONFIG>/${file} INPUT ${PROJECT_SOURCE_DIR}/${file})
endforeach()
I would also like to mention a second way of solving this problem I discovered that I think is actually more correct, by adding a custom command:
add_custom_command(TARGET target ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCES_DIR}/foo $<TARGET_FILE_DIR:target>)
Is there any way in CMake how to call a command that changes the generated .vcxproj files?
I want to patch some things within the auto generated files.
The problem is !when! to call such a tool within the cmake generation process.
I am using cmake to generate project files for a C++ project that needs to be compiled under Visual Studio 6 and 2010. The files are generated OK for both projects and I can build the projects without a problems.
However, the 2010 vxproj files contain relative paths to the cpp files and when I use Jenkins to build the files the log contains relative paths that Jenkins can not use to find the source files.
I see this:
..\..\source\moduleA\file1.cpp(74): warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
While it should have been either source/moduleA/file.cpp or D:\jenkins\jobs\workspace\source\moduleA\file.cpp for Jenkins to be able to find the file.
Of course, I can make a parser to parse the log file and remove the ..\...\ but I am hoping to find a more elegant solution.
In the end I found a compiler option that can fix this. You can add the /FC flag for Visual Studio 2010. Not sure if it works for VC6. To add it use this:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC")
What is the need of Make File? IN which situation we have to alter that file for Brew Application?
The makefile is usually used to build for the device (ARM) build of the project (with visual studio being used to build for the emulator). Visual Studio will run the makefile when you do the device build.
Small addition - makefiles used in Visual Studio only for MOD1 application, whereas they aren't used for compiling MOD apps.
As joseph said makefiles are used to build the source files in linux projects, advantage of makefile is you can write a general script irrespective of dependency files. and even if you change a single file in your file then you dont have to compile the whole source code again. only the file which is changed is compiled again and the files which are dependent on them are compiled. you can check out tutorial on the makefile at http://sagarsakre.blogspot.in/2012/09/understanding-makefile-for-beginners.html .....