Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cmake_minimum_required(VERSION 3.9)
- project(cmake-target-link-libs-strange-genexps LANGUAGES C)
- file(WRITE "hello.h"
- [[
- void hello(void);
- ]])
- file(WRITE "hello.c"
- [[
- #include <hello.h>
- #include <stdio.h>
- void hello(void) { puts("Hello"); }
- ]])
- file(WRITE "main.c"
- [[
- #include <hello.h>
- int main(void) { hello(); return 0; }
- ]])
- add_executable(main "main.c")
- add_library(hello "hello.c")
- target_include_directories(hello PUBLIC "${CMAKE_SOURCE_DIR}")
- if (something)
- message(STATUS "not printed by default, of course")
- endif ()
- target_link_libraries(main PRIVATE $<$<BOOL:something>:hello>) # evaluates to "hello", wait what?
Add Comment
Please, Sign In to add comment