Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WindowsToolchain and cleanup #5

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update WindowsToolchain and cleanup
ClausKlein committed Nov 27, 2024
commit 300c539fccca9dba263420bcc5e0e18df16583ae
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.30...3.31)

include(cmake/prelude.cmake)

project(cxx_modules_example VERSION 0.1.0 LANGUAGES CXX)
# XXX project(cxx_modules_example VERSION 0.2.0 LANGUAGES CXX)
project(my_package VERSION 0.2.0 LANGUAGES CXX)

# This property setting also needs to be consistent between the
# installed shared library and its consumer, otherwise most
@@ -23,6 +24,8 @@ if(PROJECT_IS_TOP_LEVEL)
include(cmake/spell-targets.cmake)
endif()

set(CMAKE_DEBUG_POSTFIX D)

# Disable clang-tidy for target
macro(target_disable_clang_tidy TARGET)
find_program(CLANGTIDY clang-tidy)
@@ -49,6 +52,7 @@ endmacro()
# endif()

add_library(Algo SHARED)
add_library(my_package::Algo ALIAS Algo)

target_sources(Algo
PRIVATE
@@ -97,6 +101,7 @@ if(NOT CMAKE_SKIP_INSTALL_RULES)
install(EXPORT my_package-targets
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/my_package
CXX_MODULES_DIRECTORY .
NAMESPACE my_package::
)
install(
FILES "${PROJECT_BINARY_DIR}/my_package-config-version.cmake"
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@
"inherits": [
"ci-std"
],
"generator": "Ninja Multi-Config",
"generator": "Ninja",
"description": "This build is only available on Windows",
"hidden": true,
"cacheVariables": {
9 changes: 5 additions & 4 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.28...3.31)
cmake_minimum_required(VERSION 3.30...3.31)

project(cmake-init-modulesExamples CXX)

@@ -8,7 +8,7 @@ if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_CXX_EXTENSIONS FALSE)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

find_package(my_package 0.1 QUIET)
find_package(my_package 0.2 QUIET)
if(NOT my_package_FOUND)
message(STATUS "find_package(my_package) was NOT found, use as subproject ...")
# test if the targets are usable if used as subproject
@@ -19,15 +19,15 @@ if(PROJECT_IS_TOP_LEVEL)
endif()

add_executable(app main.cpp)
target_link_libraries(app PRIVATE Algo)
target_link_libraries(app PRIVATE my_package::Algo)
add_test(NAME app-tests COMMAND app)

if(NOT PROJECT_IS_TOP_LEVEL)
# test if the targets are findable from the source or install directory
# cmake-format: off
add_test(NAME find-package-test
COMMAND ${CMAKE_CTEST_COMMAND}
# --verbose
--verbose
--output-on-failure
-C $<CONFIG>
--build-and-test
@@ -40,6 +40,7 @@ if(NOT PROJECT_IS_TOP_LEVEL)
"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
"-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}"
# FIXME: needed for multi-type generators "--config $<CONFIG>"
)
# cmake-format: on
endif()
3 changes: 2 additions & 1 deletion std/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import std; // When importing std.compat it's not needed to import std.
import std.compat;

auto main() -> int {
auto main() -> int
{
std::cout << "Hello modular world\n";
::printf("Hello compat modular world\n");
}