I am trying to compile a Library using CMAKE-gui 3.0.2 and Visual Studio express 2013.
Everything seems to be fine during the configuration/generation process in cmake-gui, as I am able to set the CMAKE_INSTALL_PREFIX variable to the path in which I want to have my library installed. And I got no errors during configuration and generation.
I then open the generated .sln file in which I can build the ALL_BUILD target, which runs smoothly with no errors and no targets skipped.
However, the INSTALL target is simply not present in the Solution Explorer, therefore I really do not have any idea on how to install the library.
Upon further inspection, I noticed that cmake did create a file called cmake_install.cmake, but I don't know what should I do with it.
CMake will only generate the INSTALL target when there is actually anything to install. It would seem you have no install() commands in your project.
Presence of the variable CMAKE_INSTALL_PREFIX does not imply anything - the variable is always present, and is used to control the installation destination when there is anything to install.
Likewise, the file cmake_install.cmake is always created; but if you inspect it, you'll find it's basically a no-op in your case (probably just some messages, setting CMake variables and possibly creating a manifest which is not used for anything).
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...
Where is the Visual Studio solution for FreeGLUT 3.0.0? I know the 2.8.1 has one, but 3.0.0 does not. I would really like to use the latest version.
Use the included CMakeLists.txt to create a Visual Studio solution:
How to build freeglut with CMake on Windows (MS Visual Studio)
Download CMake (http://www.cmake.org/cmake/resources/software.html).
Get one of the releases from the binary distribution section.
Run the CMake installer, install wherever you like.
Launch CMake via Start > Program Files > CMake 2.8 > CMake (GUI)
(note that the shortcut put by the installer on your desktop does NOT
point to the CMake GUI program!)
In the "Where is the source code" box, type or browse to the root
directory of your freeglut source (so that's /freeglut, not
/freeglut/src).
In the "Where to build the binaries" box, type or browse to any
folder you like - this will be where the Visual Studio solution will be
generated. This folder does not have to exist yet.
Hit the Configure button near the bottom of the window.
Pick your target compiler, make sure that its installed on your
system of course!
Answer Ok when asked if you want to create the build directory.
Wait for the configure process to finish.
The screen will now have some configuration options on it, for
instance specifying whether you want to build static and/or shared
libraries (see below for a complete list). When you've selected your
options, click the Configure button again.
The Generate button at the bottom will now be enabled. Click Generate.
The build files will now be generated in the location you picked.
You can now navigate to the build directory you specified in step 5.
Open the freeglut.sln file that was generated in your build directory,
and compile as usual
I have a cross-platform project which uses cmake in order to generate Visual Studio solution files. The project has external dependencies (.dlls, resources etc) and the only place where the executable can be run is the installation directory. In that directory I have access all the resources, plugins, translations etc. I can install the project both in debug or release in that directory.
How can I debug a project in the installed location?
There are two problems with this case:
Sometimes I may debug the main application (Main.exe) (a target in cmake project)
Sometimes I may debug some plugins that Main.exe loads when started (I have a different cmake project for the plugins)
Is there a clean way of doing this in Visual C++ without actually create some custom project that is configured to start each time the Main.exe from the installed location? ("C:\Program Files\MainProject\Main.exe" )
Thank you,
Iulian
I managed to do it by 'configuring' with cmake a .user file for the specified project.
The only thing that the user needs to do is to use a template like in this bitbucket project.
In the project you can find a template file.
The cmake script command needed is:
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/scripts/windows/VS201x_Template.vcxproj.user.in"
"${PROJECT_BINARY_DIR}/INSTALL.vcxproj.user"
)
If you need a custom .user file you can always do it manually by saving the generated Visual Studio and creating a template from it similarly to the above example.
I am learning how to use OpenCV and as practice I ran a program (in Release mode, x64). I had 0 compiler errors but got a pop-up screen that said:
"the program can't start because opencv_core243.dll is missing"
However, I made sure I declared the correct environment variables and specified the necessary libraries/directories. My problem was fixed when I copied the following .dll files into x64/Release:
opencv_core243.dll
opencv_highgui243.dll
opencv_imgproc243.dll
My program compiles fine now and works. However, I would like to know why. It feels cheap to copy and paste these .dll files. Did I miss a step where these .dll files would be generated automatically?
The actual solution for this problem is to append the path of opencv bin directory to the System PATH environment variable.
Have a look at this answer describing the complete procedure to install OpenCV in Visual Studio 2010.
There is a disadvantage of this approach. The prebuilt OpenCV x86 and x64 binaries have same names. So by appending the path of OpenCV to the PATH variable, you can execute either the 32 bit version or the 64 bit version at a time. To run the other version, you have to change the PATH variable.
An alternative to this, (my personal favorite) also involves copying the dlls to output directory, but this is done automatically at the end of compilation. What I do, is to create new environment variables for x86 and x64 dll paths. I create the User Variables CV_BIN32 and CV_BIN64 containing the paths of x86 and x64 dlls respectively.
After creating the User Variables, open your OpenCV project, go to Project Properties -> Build Events -> Post-Build Event -> Command Line.
Add the copy commands for the dlls you require at the runtime.
This one is for Win32 Release Configuration:
copy "$(CV_BIN32)\opencv_core243.dll" "$(OutDir)"
copy "$(CV_BIN32)\opencv_highgui243.dll" "$(OutDir)"
You can change them for all the 4 configurations, (Debug/Release),(Win32/x64)
Now when the project build procedure completes, the specified dlls will be copied to the output directory automatically, and the error will not be shown.
In VS 2008 and VS 2010, one can easily create a solution and modify the "Solution Configuration". We can choose what configuration each project gets built in when we trigger a build at the solution level.
Is such a facility available in the Visual Studio 6.0?
In my experience:
when a configuration is chosen (form the list available) in VS6 for a VC++ project, the dependencies (which themselves have multiple configurations defined) get built in some random order. There is no way to control the configurations of dependencies at build time.
"Batch Build" does come close to this but is not as flexible for my purpose.
I have tried various options in the VS6.
Hope I am clear.
Here is a link on the MSDEV command line.
https://msdn.microsoft.com/en-us/library/aa699274(v=vs.60).aspx
There is a way to control the building of dependencies. Specify /NORECURSE and dependencies will not be built.
I use /REBUILD with /NORECURSE to keep the dependencies from getting built.
And I build each project one at a time inside the workspace in a bat file by doing a chdir to the subdirectory and calling MSDEV just for that subproject:
msdev myproject.dsp /MAKE "myproject - Win32 Debug" /REBUILD /NORECURSE > Build.log
Then I cd to the next project directory one at a time.
On a side note, I had difficulties for several years where NMAKE would not work for my specific tasks. Turns out that the PATH environment variable inside MSDEV (Visual Studio 6.0) is different from the PATH environment variable of a command shell you would run NMAKE on.
The Path used by the MSDEV shell is the %PATH% at the time Visual Studio 6 was installed. We use this and poke the registry as needed for MSDEV to get the correct path setup when switching revisions of our software; however this doesn't help update the %PATH%. The MSDEV path can be queried with a query script. I don't have my example handy.
That is why builds in MSDEV sometimes work when builds using the command line don't, as the path to DLLs differ, and any custom build steps that run .exe will not work outside of the MSDEV environment unless the path is updated.
I have a script somewhere that reads the queries the registry to extract the MSDEV path and update PATH of a shell so that batch scripts doing nmake will work as they would inside the MSDEV shell environment. The problem with the REGISTRY QUERY is that the return arguments differ with different flavors of Windows (XP/SERVER2003/...).
One thing I just discovered is that Incredibuild works with the old VS6.0 MSDEV IDE. This is a game changer. It distributes builds. I'm evaluating it now, but it might be useful to anyone waiting for long VS6.0 builds.