Manu343726 / siplasplas

A library for C++ reflection and introspection
https://manu343726.github.io/siplasplas
MIT License
195 stars 27 forks source link

Include paths confusion #79

Open sztomi opened 7 years ago

sztomi commented 7 years ago

So I finally managed to integrate siplasplas into a build. I have a source tree that looks like this:

build/
include/
    |--- myenum.hpp
src/
    |--- main.cpp

I'm a bit confused about whether I need to add extra include paths after running siplasplas. When my build invokes siplasplas, it generates the output code into the above structure like this:

build/
    |--- output/
             |--- reflection/
                       |--- include/
                                 |--- myenum.hpp
include/
    |--- myenum.hpp
src/
    |--- main.cpp

So when I run my build it won't compile #include "reflection/myenum.hpp". If I include reflection/include/myenum.hpp it does work. Is this how it's supposed to work or am I doing something wrong? I feel that stripping the first component of the include dir in the generated tree is more intuitive.


I used this release: https://github.com/Manu343726/siplasplas/releases/tag/0.0.2-1 and boostrap.cmake.

main.cpp looks like this:

#include "myenum.hpp"
#include "reflection/myenum.hpp"

int main() {
    myenum e;
}

CMakeLists.txt:

project(ucg)
cmake_minimum_required(VERSION 3.0.0)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

set(SIPLASPLAS_PACKAGE_URL https://github.com/Manu343726/siplasplas/releases/download/0.0.2-1/siplasplas-master-GNU-6_2_1-Debug-dynamic.tar.gz)
set(SIPLASPLAS_INSTALL_DRLPARSER_DEPENDENCIES ON) # Download DRLparser deps with pip
set(SIPLASPLAS_LIBCLANG_VERSION 3.8.0) # libclang version
set(SIPLASPLAS_DOWNLOAD_LIBCLANG ON) # Download and configure libclang automatically
include(cmake/bootstrap.cmake)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

set(UCG_SRCS src/main.cpp include/myenum.hpp)

add_executable(ucg ${UCG_SRCS})

target_include_directories(ucg PUBLIC include/)
configure_siplasplas_reflection(ucg)

target_link_libraries(ucg ${CONAN_LIBS})
Manu343726 commented 7 years ago

Hi,

The configure_siplasplas_reflection() function reads the properties of your target to invoke DRLParser with the right arguments (sourcetree root, include dirs, search dirs, blacklist, etc). The behavior is as follows:

There are more options, but I will end up writing a doc page for this :)

Your problem may be fixed by setting your include/ dir as DRLParser sourcedir, but there's currently no option to do that in the cmake function (You can always edit your drlparser.cmake file and change the value passed to the -s option to see what happens). Maybe the right solution is to change the semantics and set an includetree instead of a sourcetree.

If you experiment more problems like this in the future, consider enabling verbose DRLParser processing (SIPLASPLAS_VERBOSE_DRLPARSER cmake variable) to see what's exactly going on.

Manu343726 commented 7 years ago

Hi again,

I forgot to say that I'm not going to close this until this sourcedir -> includedir semantics are fixed, regardless of your specific issue which I think can be solved with a workaround ;)

Thanks a lot for pointing out this issue.

sztomi commented 7 years ago

Thanks for the very detailed response. I'm going to take a look and see if I can solve my specific problem based on this.