Skip to content

ANaumann85/example-for-libxlsxwriter-issue-318

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example for issue-318

repository content

The repository consists only of

  1. the submodule libxlsxwriter at Release_1.0.0.
  2. one CMakeLists.txt which adds the submodule as additional folder.
  3. the demo in src/demo.c from the libxlsxwriter repository. But that serves only as an example for compiling and linking.

The Cause

The problem can be seen with the following commands:

mkdir build
cd build
cmake .. 2> err_1
cmake .. 2> err_2
make

Due to the second cmake run, the compilation of the demo fails with the error message

fatal error: xlsxwriter.h: No such file or directory 

The (error) output already give hints to the reason for the failure, namely the targets name change.

Explanations

The CMakeLists.txt in the folder libxlsxwriter creates a target, which represents the library xlsxwriter. But the actual name of the target is different between the first and all later cmake runs. To make that behavior clear, the CMakeLists.txt prints either "has the target xlsxwriter" (in the first run) or "has the target testIssue_318" (in the second run). Hence the reference in line 15 in CMakeLists.txt does not refer to the target.

To explain that behavior, we consider the content and the type of the variable PROJECT_NAME in two lines:

file line first run second run
content type content type
CMakeLists.txt 3 testIssue_318 ordinary testIssue_318 cache
libxlsxwriter/CMakeLists.txt 96 testIssue_318 ordinary testIssue_318 cache
libxlsxwriter/CMakeLists.txt 98 libxlsxwriter cache testIssue_318 cache

That type and value changes are explained in the cmake documentation

If the cache entry does not exist prior to the call or the FORCE option is given then the cache entry will be set to the 
given value. Furthermore, any normal variable binding in the current scope will be removed to expose the newly
cached value to any immediately following evaluation.

In our case

  1. in the first run, we change the type from ordinary to cache, AND the value from testIssue_318 to xlsxwriter.
  2. in the second run, we keep the type AND the value, but from the outer project name.

About

provides an explanatory example for the issue 318

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published