TartanLlama / expected

C++11/14/17 std::expected with functional-style extensions

Home Page:https://tl.tartanllama.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with cmake

SasLuca opened this issue · comments

Note: I suck at CMake so this might not be a bug but rather a misunderstanding on my part.

For my project, I use CLion on Windows with CMake and git submodules for libraries.
I add libraries to my .gitmodules file and then in my CMakeLists.txt file I do add_subdirectory(libs/expected).

In my .gitmodules the library is included as such:

[submodule "libs/expected"]
	path = libs/expected
	url = https://github.com/TartanLlama/expected

When I sync CMake after including expected it gives an error:

CMake Error at libs/expected/CMakeLists.txt:35 (add_executable):
  add_executable cannot create ALIAS target "tl::expected" because target
  "expected" is not an executable.

To fix this error I modify expected\CMakeLists.txt by removing commenting the following lines:

34 | #if (NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
35 | #  add_executable(tl::expected ALIAS expected)
36 | #endif()

I have no idea why these lines cause an error and my knowledge of CMake is very limited, but every other library I use works fine by default.

If anyone can provide a solution for this or investigate if it's an actual issue that would be cool.
If there is something that I missed in terms of how to use the library with CMake maybe it would be nice to mention in the readme how to avoid this issue? At the very least I hope if someone else ever deals with this they can find a solution here.

Thanks, it should have been add_library. Fixed in master.