jmcnamara / libxlsxwriter

A C library for creating Excel XLSX files.
https://libxlsxwriter.github.io
Other
1.51k stars 333 forks source link

Feature request: support cmake import with sub_directory #318

Closed ANaumann85 closed 3 years ago

ANaumann85 commented 3 years ago

I would like to add the library in cmake as a subdirectory with a simple

add_subdirectory(libxlsxwriter )

call.

But at the release 1.0.0 (and master too), that does not work directly. Because in your CMakeLists.txt, line 97 the variable "PROJECT_NAME" is set as a cache variable. That means

jmcnamara commented 3 years ago

@evanmiller or @Alexhuszagh Does this CMake change seem reasonable?

evanmiller commented 3 years ago

@jmcnamara I am not familiar enough with CMake variables to offer an opinion here.

ANaumann85 commented 3 years ago

would further comments or links to the documentation help?

jmcnamara commented 3 years ago

@ANaumann85 Yes. Any additional explanation would be good. I don't really understand what the issue is.

However, it would probably be more helpful to describe the issue that you are having in your project (with some commandline examples if possible) rather than a general explanation of potential issues.

ANaumann85 commented 3 years ago

I created a small working example.

The example imports the libxsxwriter as a sub directory and tries to compile a copy of your demo.c. That works fine, as long as one runs cmake only once.

But after a second cmake run, the target for the library xlsxwriter gets another name, the demo looses the relation to the library and therefore it looses the include path to the libxslxwriter.