You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if i understand correctly, this is still something for the future, but to my understanding it's not possible to make libraries with cpp2 files.
e.g., i followed a module example:
cmake file:
cmake_minimum_required(VERSION 3.30)
project(cpp2test LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(FetchContent)
FetchContent_Declare(
cppfront
GIT_REPOSITORY https://github.com/modern-cmake/cppfront.git
GIT_TAG main # or an actual git SHA if you don't like to live dangerously
)
FetchContent_MakeAvailable(cppfront)
add_library(foo)
# Add the module file to the library
target_sources(foo
PUBLIC
FILE_SET CXX_MODULES FILES
Shape.cpp
)
set_target_properties(foo PROPERTIES LINKER_LANGUAGE CXX)
# Create an executable
add_executable(cpp2test main.cpp2)
# Link to the library foo
target_link_libraries(cpp2test PUBLIC foo)
with Shape.cpp
export module Shape;
export int add(int a, int b) {
return a + b + 42;
}
this compiles and runs. but i get errors as soon as i rename Shape.cpp to Shape.cpp2:
[cmake] CMake Error in CMakeLists.txt:
[cmake] Target "foo" has source file
[cmake]
[cmake] /home/madam/Documents/cpp2test/Shape.cpp2
[cmake]
[cmake] in a "FILE_SET TYPE CXX_MODULES" but it is not scheduled for compilation.
i already added set_target_properties(foo PROPERTIES LINKER_LANGUAGE CXX), but it appears that that's not enough.
The text was updated successfully, but these errors were encountered:
@adam-ce -- I meant to merge that, but I got distracted by the various CI issues and then my day job got busier. Do you have any bandwidth to help out with CI?
i'm not a CI expert at all and i'm not really familiar with mac. in my own setup i ended up deleting the CI tests on Macos because they were failing too often (timeouts as well, but i was starting an android simulator).
besides that, no. i don't have available bandwidth, not even for my own pet project :/
if i understand correctly, this is still something for the future, but to my understanding it's not possible to make libraries with cpp2 files.
e.g., i followed a module example:
cmake file:
with Shape.cpp
and main.cpp2
this compiles and runs. but i get errors as soon as i rename Shape.cpp to Shape.cpp2:
i already added
set_target_properties(foo PROPERTIES LINKER_LANGUAGE CXX)
, but it appears that that's not enough.The text was updated successfully, but these errors were encountered: