I tried to work with file sets and the IN_LIST generator expression. My code looks like in the listing below.
cmake_minimum_required(VERSION 3.24)
set(TARGET_NAME alice)
add_library(${TARGET_NAME}
src/alice.c
)
target_sources(${TARGET_NAME} PUBLIC FILE_SET HEADERS TYPE HEADERS
BASE_DIRS
"$<$<IN_LIST:${CMAKE_SYSTEM_PROCESSOR},x86_64;x86>:${CMAKE_CURRENT_LIST_DIR}/include/var/${CMAKE_SYSTEM_PROCESSOR}>"
# "$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},x86>:${CMAKE_CURRENT_LIST_DIR}/include/var/${CMAKE_SYSTEM_PROCESSOR}>"
# "$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},x86_64>:${CMAKE_CURRENT_LIST_DIR}/include/var/${CMAKE_SYSTEM_PROCESSOR}>"
FILES
"$<$<IN_LIST:${CMAKE_SYSTEM_PROCESSOR},x86_64;x86>:${CMAKE_CURRENT_LIST_DIR}/include/var/${CMAKE_SYSTEM_PROCESSOR}/arch_specifics.h>"
# "$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},x86>:${CMAKE_CURRENT_LIST_DIR}/include/var/${CMAKE_SYSTEM_PROCESSOR}/arch_specifics.h>"
# "$<$<STREQUAL:${CMAKE_SYSTEM_PROCESSOR},x86_64>:${CMAKE_CURRENT_LIST_DIR}/include/var/${CMAKE_SYSTEM_PROCESSOR}/arch_specifics.h>"
)
install(TARGETS ${TARGET_NAME} EXPORT export_all FILE_SET HEADERS)
When using the IN_LIST genex, CMake reports errors.
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64/arch_specifics.h>
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64/arch_specifics.h>
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64/arch_specifics.h>
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error in src/alice/CMakeLists.txt:
Found relative path while evaluating include directories of "alice":
"$<BUILD_INTERFACE:$<1"
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64/arch_specifics.h>
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
CMake Error at src/alice/CMakeLists.txt:12 (target_sources):
File:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64/arch_specifics.h>
must be in one of the file set's base directories:
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/$<$<IN_LIST:x86_64,x86_64
/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/x86>:/home/ds/prj/cmake_snippets/examples/generator_expressions/in_list/src/alice/include/var/x86_64>
However, when using STREQUAL genex instead, everything works as expected.
I have made an example here
Could someone help me understanding the behavior of IN_LIST genex in this context?