[GH-ISSUE #318] Feature request: support cmake import with sub_directory #256

Closed
opened 2026-05-05 12:03:04 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @ANaumann85 on GitHub (Dec 21, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/318

Originally assigned to: @jmcnamara on GitHub.

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

  • if the variable was set as cache variable before, the content will not be changed. Therefore your library gets the corresponding.
  • if the variable was set as non-cache variable, it changes between different cmake runs:
    1. In the first run, you add the library with name xlsxswriter
    2. starting from the second run, you add the library under the name of the surrounding project
Originally created by @ANaumann85 on GitHub (Dec 21, 2020). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/318 Originally assigned to: @jmcnamara on GitHub. I would like to add the library in cmake as a subdirectory with a simple ```[cmake] 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](https://github.com/jmcnamara/libxlsxwriter/blob/59e15dd3ac79a6f0e11f8427cdd236354e4250bd/CMakeLists.txt#L97) the variable "PROJECT_NAME" is set as a cache variable. That means * if the variable was set as cache variable before, the content will not be changed. Therefore your library gets the corresponding. * if the variable was set as non-cache variable, it changes between different cmake runs: 1. In the first run, you add the library with name xlsxswriter 2. starting from the second run, you add the library under the name of the surrounding project
gitea-mirror 2026-05-05 12:03:04 -06:00
Author
Owner

@jmcnamara commented on GitHub (Dec 22, 2020):

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

<!-- gh-comment-id:749704230 --> @jmcnamara commented on GitHub (Dec 22, 2020): @evanmiller or @Alexhuszagh Does this CMake change seem reasonable?
Author
Owner

@evanmiller commented on GitHub (Dec 22, 2020):

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

<!-- gh-comment-id:749710204 --> @evanmiller commented on GitHub (Dec 22, 2020): @jmcnamara I am not familiar enough with CMake variables to offer an opinion here.
Author
Owner

@ANaumann85 commented on GitHub (Dec 22, 2020):

would further comments or links to the documentation help?

<!-- gh-comment-id:749717268 --> @ANaumann85 commented on GitHub (Dec 22, 2020): would further comments or links to the documentation help?
Author
Owner

@jmcnamara commented on GitHub (Dec 22, 2020):

@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.

<!-- gh-comment-id:749833397 --> @jmcnamara commented on GitHub (Dec 22, 2020): @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.
Author
Owner

@ANaumann85 commented on GitHub (Dec 24, 2020):

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.

<!-- gh-comment-id:750625021 --> @ANaumann85 commented on GitHub (Dec 24, 2020): I created a small [working example](https://github.com/ANaumann85/example-for-libxlsxwriter-issue-318). 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#256
No description provided.