-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C++] Add definition for __PROJECT_SOURCE_DIR__ to aeron_client's pub…
…lic interface. This is required in case there is an upper level directory that includes Aeron. In that case the added definitions do not reach the source files that may include Aeron headers and __PROJECT_SOURCE_DIR__ will be undefined to them.
- Loading branch information
1 parent
eabd7d6
commit 435e276
Showing
2 changed files
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I'm not sure this has fixed the issue. At least I'm coming up with the missing PROJECT_SOURCE_DIR error in my recent compiles. I'm pulling a mirror as an external_project in my root CMakeLists.txt
435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. I presume you use
ExternalProject_Add
for your project. Are you linking againstaeron_client
usingtarget_link_libraries
?435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I am doing as your mentioned above with ExternalProject_Add and using target_link_libraries to link with aeron_client. Is there a work around to get my app building again?
435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If folks are having issues would it be possible to reproduce your issue in the travis build, or at least post details about how to reproduce the problem?
435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi LukePalmer,
I believe the issue is that the new PROJECT_SOURCE_DIR value is defined when the aeron_client library is built but when I try to include a header to use the library the value is no longer defined.
Building your library and code works fine but trying to use the resulting library by including a header file causes the error when I build my application.
The compiler error I get is:
In file included from /home/Code/thirdparty_external/aeron/aeron-client/src/main/cpp/Aeron.h:20:0,
/home/Code/thirdparty_external/aeron/aeron-client/src/main/cpp/util/StringUtil.h: In function ‘valueType aeron::util::parse(const string&)’:
/home/Code/thirdparty_external/aeron/aeron-client/src/main/cpp/util/Exceptions.h:34:49: error: ‘PROJECT_SOURCE_DIR’ was not declared in this scope
#define SHORT_FILE aeron::util::past_prefix(PROJECT_SOURCE_DIR,FILE)
435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that makes sense.
Haven't actually tried this yet but how about something like this in Exceptions.h:
435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me test it with
ExternalProject_Add
, it runs in build time so potentially target level definitions are not passed to your code that links against it.435e276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, importing a library at build time does not import its target level definitions or its include directories. What you may do to alleviate it if you want the relative paths in your exceptions is to manually add the definition.
Here is a sample project that uses
ExternalProject_Add
with Aeron.https://github.com/denizevrenci/aeron_as_external_proj
But I suggest switching to https://github.com/Crascit/DownloadProject if you have CMake < 3.11 or https://cmake.org/cmake/help/v3.11/module/FetchContent.html otherwise. They run at configure time so you are able to add Aeron project root with
add_subdirectory
. That way you won't have to import the archive file or manually add include directories, libraries or definitions.