Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

CXX_COMPILER_ID generator expression in compile definitions #135

@JoshCollins746

Description

@JoshCollins746

I am trying to use the GSL (https://github.com/Microsoft/GSL) with cotire in a project. GSL adds compile definitions to the INTERFACE target using generator expressions:

target_compile_definitions(GSL INTERFACE
    $<$<CXX_COMPILER_ID:MSVC>:
        # remove unnecessary warnings about unchecked iterators
        _SCL_SECURE_NO_WARNINGS
    >
)

When I run cotire 1.7.10 on my target after linking to this library I get the following error:

CMake Error at cotire/CMake/cotire.cmake:2254 (file):
  Error evaluating generator expression:

    $<CXX_COMPILER_ID:MSVC>

  $<CXX_COMPILER_ID> may only be used with binary targets.  It may not be
  used with add_custom_command or add_custom_target.
Call Stack (most recent call first):
  cotire/CMake/cotire.cmake:2848 (cotire_generate_target_script)
  cotire/CMake/cotire.cmake:3254 (cotire_process_target_language)
  cotire/CMake/cotire.cmake:3431 (cotire_target)
  CMakeLists.txt:16 (cotire)

It seems that cotire does not like these generator expressions. A minimal reproduction is:

cmake_minimum_required(VERSION 3.7)
project(Test CXX)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cotire/CMake")
include(cotire)

add_executable(Test main.cpp)

target_compile_definitions(Test PUBLIC $<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>)

cotire(Test)

I have tested with both cmake 3.7 and 3.9.

I tried running cotire before adding the target_compile_options which removes the error, but I get the impression that this means that the definition is being ignored by cotire which seems would cause other issues.

I do not know if this is an error with Cotire or with the way that I am using it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions