alanxz / SimpleAmqpClient

Simple C++ Interface to rabbitmq-c
MIT License
398 stars 214 forks source link

CMake results for Visual Studios error / enhancement #106

Open stevehickman opened 9 years ago

stevehickman commented 9 years ago

CMake generated SimpleAmqpClient project for Visual Studio 2012 prefixes the rabbitmq-c include directory with the directory where the SimpleAmqpClient source is. In addition, if CMake is given the rabbitmq-c include directory as an environment variable, it should be converted from %env_var% to $(env_var)

Also, the boost and rabbitmq-c libraries specified to the linker are fully qualified. A better approach would be to specify link directories to look in. For example, 'Additional Library Directories' could be: $(RABBITMQ_CLIENT_HOME)/lib;$(BOOST_LIB)/lib$(PlatformArchitecture)-msvc-$(CrtSDKReferenceVersion);%(AdditionalLibraryDirectories)

Note that in '/lib$(PlatformArchitecture)-msvc-$(CrtSDKReferenceVersion);%(AdditionalLibraryDirectories)' $(PlatformArchitecture) will be either 32 or 64 and $(CrtSDKReferenceVersion) will specify the current version of Visual Studio. These will get interpreted properly automatically.

stevehickman commented 9 years ago

the test_api project has the same issue

stevehickman commented 9 years ago

Also - the rabbitmq library name supplied is incorrect. It needs to be changed to librabbitmq.4.lib

alanxz commented 9 years ago

Interesting, that means that the find_library CMake built-in isn't doing what It should be. What version of CMake are you using to generate the project files?

stevehickman commented 9 years ago

Version 3.3.1

stevehickman commented 9 years ago

I used the CMake GUI if that matters. I’m a CMake novice.

stevehickman commented 8 years ago

This problem remains when using the CMake 3.5 GUI

stevehickman commented 8 years ago

It turns out all the projects have the same issue with prefixing. I made the following global replacements in all my .vcxproj files:

Replaced: D:\Freeware\AMPQ related\SimpleAmqpClient-master\%RABBITMQ_CLIENT_HOME% with $(RABBITMQ_CLIENT_HOME) --- This change fixes the error that prevents the projects from finding RabbitMQ C client headers.

Replaced: D:\Boost\boost_1_58_0 with $(BOOST_HOME) --- This change makes it possible to change which boost libraries I link to without regenerating the projects. I simply change with version of Boost the $(BOOST_HOME) environment variable points to.

I should also note that there is no need to refer to specific boost libraries in the project files. Boost Auto Linking will take care of this. See http://www.boost.org/doc/libs/1_60_0/boost/config/auto_link.hpp

stevehickman commented 8 years ago

Further, referring to specific boost libraries makes the project depend on that specific version of boost. Removing those library references and using autolinking finishes the change to $(BOOST_HOME) described above to make it possible to update to new versions of Boost easily.