Skip to content

[Bug] Build fails during CMake generation: No target "scantailor" (Outdated target name in CMake scripts) #174

Description

@astrol7

Environment:
OS: Windows 11
Build environment: MSYS2 (UCRT64)
CMake toolchain: Ninja, Qt6

Bug Description:
When attempting to configure and generate the build files using CMake, the process fails at the very end (Generation step) with the following error:

CMake Error at cmake/CopyToBuildDir.cmake:62 (add_custom_target):
  Error evaluating generator expression:

    $<TARGET_FILE_DIR:scantailor>

  No target "scantailor"
Call Stack (most recent call first):
  CMakeLists.txt:457 (generate_copy_to_build_dir_target)

Root Cause:
The bug occurs because the main executable is defined with the name scantailor-advanced in src/app/CMakeLists.txt (via set(target_name scantailor-advanced)), but several CMake scripts are still using the hardcoded old name scantailor.

Since the target scantailor does not exist, the generator expression fails, breaking the build—especially on Windows where CopyToBuildDir.cmake is used to deploy DLLs. It also breaks the translation targets in the root CMakeLists.txt.

Proposed Solution:
The hardcoded strings need to be updated to match the new target name. Replacing scantailor with scantailor-advanced (or using the ${target_name} variable if applicable) in the following files fixes the build entirely:

  1. In cmake/CopyToBuildDir.cmake (around line 62):
    Change:
    $<TARGET_FILE_DIR:scantailor>
    To:
    $<TARGET_FILE_DIR:scantailor-advanced>

  2. In root CMakeLists.txt (around lines 334-335):
    Change:
    finalize_translations(scantailor ${translation_files})
    update_translations_target(update_translations scantailor)
    To:
    finalize_translations(scantailor-advanced ${translation_files})
    update_translations_target(update_translations scantailor-advanced)

Applying these changes allows CMake to successfully evaluate the target and package the executable with windeployqt successfully under Qt6.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions