Skip to content

Build fails if -Wpedantic-errors or -Weverything compiler flags are set #24

Description

@kernelwernel

as the title says, the build process fails if either flags are included in my CMAKE_CXX_FLAGS. I've provided a replication of the error:

error:

CMake Error at cmake/modules.cmake:135 (add_library):
  No SOURCES given to target: MODULES
Call Stack (most recent call first):
  CMakeLists.txt:27 (add_module_library)

file structure:

.
├── cmake
│   └── modules.cmake
├── CMakeLists.txt
└── src
    ├── hello.cpp
    ├── main.cpp
    └── subdir
        └── bye.cpp

CMakeLists.txt:

cmake_minimum_required(VERSION 3.26)
project(modtest)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# this works
#set(CMAKE_CXX_FLAGS "-w -Wall -Wextra -Werror -Wshadow -Wconversion -Wunused -Wpedantic")
# but this doesn't
set(CMAKE_CXX_FLAGS "-w -Wall -Wextra -Werror -Wshadow -Wconversion -Wunused -Wpedantic -Wpedantic-errors -Weverything")

set(PROJECT "${CMAKE_CURRENT_SOURCE_DIR}")
set(TARGET "modtest")

file(GLOB_RECURSE SRC "${PROJECT}/src/*.cpp")

add_executable(${TARGET} ${PROJECT}/src/main.cpp)

include(cmake/modules.cmake)

add_module_library(MODULES ${SRC})

target_link_libraries(${TARGET} PRIVATE MODULES)

main:

import hello;
import bye;

int main() {
    hello();
    bye();
}

hello:

module;

#include <iostream>

export module hello;

export void hello() {
    std::cout << "hello\n";
}

bye:

module;

#include <iostream>

export module bye;

export void bye() {
    std::cout << "bye\n";
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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