Add Resources Include Directories to VS2015 projects with CMake - visual-studio

I'm building wireshark with Visual Studio 2015. After CMake finishes I need to manually add $(WindowsSDK_IncludePath); to the Resources -> Additional Include Directories of multiple projects in the solution. Adding the folders to the general Additional Include Directories of a project doesn't work, Only if I add to the Resources Includes it works. How do I get CMake to Add directories there?
Thanks

set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /i<path>")
If your code only works with Resource Include Directories, it must rely on the Windows Resource Compiler (rc on command line). So, adding the include directory to your CMAKE_RC_FLAGS settings, the equivalent of adding it as an /i option to rc, should fix it.

Related

cmake choose output directory .exe

I tried to define where to put the .exe generated by cmake + visual studio.
I put this in the cmakefiles.txt
IF(CMAKE_SYSTEM_NAME STREQUAL Windows)
INSTALL(TARGETS
mialsrtkRefineHRMaskByIntersection
DESTINATION ${CMAKE_INSTALL_PREFIX})
ENDIF(CMAKE_SYSTEM_NAME STREQUAL Windows)
but at the end all exe are in the folder of the vcxproj in a subfolder Debut.
is that normal ?
How can I specify the output directory ?
on linux I put destination bin and it works.
What you're setting is the installation destination directory. In Visual Studio, installation is performed by building the special target INSTALL. That is equivalent to make install in Make world.
Note that you can also specify the build output directory. The ways to do that are :
Variable CMAKE_RUNTIME_OUTPUT_DIRECTORY, which provides global settings.
Target property RUNTIME_OUTPUT_DIRECTORY, which controls settings for a particular target.
Both of these have per-configuration variants, or sister variables/properties which affect other things than executables (e.g. CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG). Please see the CMake docs for details.

How to debug cmake target after install

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.

How to get absolute paths in cmake generated project files

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")

Cannot open include file "d3dx9.h"

Edit: Of course, immediately after working on it for an hour then posting here, I found the stupid mistake...
I'm getting compiler errors when trying to #include <d3dx9.h> in a project. I'm receiving "fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory".
I do have the DirectX SDK installed (I also just tried reinstalling it to no avail).
In the Project Properties:
VC++ Directories are set to "$(DXSDK_DIR)Include;$(IncludePath)" and "$(DXSDK_DIR)Lib\x86;$(LibraryPath)" for Include and Library directories respectively for all configurations—and the environment variable %DXSDK_DIR% points to C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\ as expected.
C/C++ > General settings has $(DXSDK_DIR)include listed in the Additional Include Directories
Linker > Input > Additional Dependencies has d3dx9d.lib included for Debug and d3dx9.lib included for Release configuration.
I am able to successfully compile and run tutorial projects from the DirectX Sample Browser.
Visual Studio's Intellisense/autocomplete will find d3dx9.h and suggest type and function names that are within the file (and not included through anything else I'm #includeing) so it seems that Intellisense can find it.
Any suggestions on what I'm forgetting or what else to try?
Thanks
you forgot one thing:
Go to VC++ Directories -> Library Directories
add $(DXSDK_DIR)LIB\x86
apply.
Done. Hope this helps
You should make sure you have ALL paths sorounded by quotes (").
Instead of $(DXSDK_DIR)include you should have "$(DXSDK_DIR)include"
I didn't realize that one of the other projects in the solution was #includeing a file that was #includeing a file that was #includeing d3dx9.h and I hadn't added those paths to that project.
/facepalm
Find the file on your computer, and add it's folder to the properties of your project.
Assuming you have visual studio: Properties/C/C++/General/Additional Include Libraries.
I tried all of these suggestions and none worked.
Turns out the $(DXSDK_DIR) variable doesn't work if you install DirectX while Visual Studio is still running. The solution for me was to restart Visual Studio (+ adding the paths in the solutions listed above, of course).

How do I use libcurl in Visual C++ 2010?

Hey guys, I was wondering if you would be able to help me use libcurl within Visual Studio to resolve the errors in the image below:
It looks like you need to update Visual Studio's configuration to include the directories where you've installed cURL. VS has directories for both Include files and libraries -- if memory serves, you'll have to add both.
I too ran into same issue. The problem is, i was pointing in additinal lib dirs to lib/LIB-Debug instead lib/DLL-Debug. Also the lib to add is libcurld_imp.lib and not libcurld.lib. Also you need to copy libcurld.dll into executable file location. I see that there are lib/LIB-Debug dir and lib file but dont know what they are for. You have to do use DLL-Release, libcurl_imp.lib etc for release mode.

Resources