argtable/argtable3

CMake not including header on static build

tlf30 opened this issue · 1 comments

Hello,
I'm attempting to build a simple application, where I am statically linking against argtable3.
I am using FetchContent to bring the library into the build.

FetchContent_Declare(argtable
        SOURCE_DIR "${PROJECT_SOURCE_DIR}/deps/argtable3-master"
)
FetchContent_MakeAvailable(argtable)

And then linking to it
target_link_libraries(spyglass_core argtable3)

CMake correctly builds argtable3, but the argtable3.h is not exposed to the include path.

C:\PROGRA~1\JETBRA~1\CLION2~1.2\bin\mingw\bin\gcc.exe  -I"<censored>/src/include" -I"<censored>/deps/<censored>/include" -g -std=gnu90 -fdiagnostics-color=always -Wall -Wextra -Wpedantic -Wno-unused-parameter -MD -MT <censored>.c.obj -MF <censored>.c.obj.d -o <censored>.c.obj -c "<censored>.c"
<censored>.c:2:10: fatal error: argtable3.h: No such file or directory
    2 | #include <argtable3.h>
      |          ^~~~~~~~~~~~~

Sorry for the censorship, but the build command that CMake runs does not contain the include for argtable3.

I'm sure I am doing something wrong here, but this is working for my other dependencies.
I am using the master copy of the branch, which has the #85 merged into it.

OK,
I think I have found the issue (at least it works for me)
In #85, the build interface was set to CMAKE_CURRENT_SOURCEDIR but the variable is actually CMAKE_CURRENT_SOURCE_DIR
https://cmake.org/cmake/help/latest/variable/CMAKE_SOURCE_DIR.html

EDIT:

"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCEDIR}>"

should be fixed to say "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"