Skip to content

Commit 33fb7aa

Browse files
SidneyCogdillSidneyCogdill
andauthored
Project rename: Proxy -> Proxy 4 (#302)
* Move headers to v4 subdir * rename header guard and macros * add shim headers * rename CMake project and target names * modify CMake scripts, part 1 * modify CMake scripts, part 2 * use pro::v4 in implementation * use nested namespace declaration + move proxy.ixx to v4 subdirectory * `___PRO_4_` -> `___PRO4_` * move + improve version-less macros * rename: `PROXY_4`` -> `PROXY4` for include guards * Add include guard for shim headers * provide diagnostic for ambiguous `__msft_lib_proxy` * use version-less name for internal macros * proper diagnostic for `__msft_lib_proxy` * rename to `msft_proxy::proxy4` * undefine macro before redefine --------- Co-authored-by: SidneyCogdill <no@localhost>
1 parent 8ac85f6 commit 33fb7aa

21 files changed

+2862
-2776
lines changed

CMakeLists.txt

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
cmake_minimum_required(VERSION 3.28)
22

3-
project(msft_proxy VERSION 3.3.0 LANGUAGES CXX)
4-
add_library(msft_proxy INTERFACE)
3+
project(msft_proxy4 VERSION 3.3.0 LANGUAGES CXX)
4+
add_library(msft_proxy4 INTERFACE)
5+
set_target_properties(msft_proxy4 PROPERTIES EXPORT_NAME proxy4)
6+
add_library(msft_proxy::proxy4 ALIAS msft_proxy4)
57

68
# Do not enable building tests if proxy is consumed as
79
# subdirectory (e.g. by CMake FetchContent_Declare).
@@ -19,7 +21,7 @@ if(PROJECT_IS_TOP_LEVEL)
1921
)
2022
endif()
2123

22-
target_sources(msft_proxy
24+
target_sources(msft_proxy4
2325
INTERFACE
2426
FILE_SET public_headers
2527
TYPE HEADERS
@@ -28,53 +30,64 @@ target_sources(msft_proxy
2830
include/proxy/proxy.h
2931
include/proxy/proxy_macros.h
3032
include/proxy/proxy_fmt.h
31-
include/proxy/proxy.ixx
33+
include/proxy/v4/proxy.ixx
34+
include/proxy/v4/proxy.h
35+
include/proxy/v4/proxy_macros.h
36+
include/proxy/v4/proxy_fmt.h
3237
)
3338

34-
target_compile_features(msft_proxy INTERFACE cxx_std_20)
35-
target_include_directories(msft_proxy INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
39+
target_compile_features(msft_proxy4 INTERFACE cxx_std_20)
40+
target_include_directories(msft_proxy4 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
3641
$<INSTALL_INTERFACE:include>)
3742

3843
# Do not set the module target if proxy is consumed as a subdirectory.
3944
if(PROJECT_IS_TOP_LEVEL)
40-
set(proxy_INCLUDE_DIR include)
45+
set(proxy4_INCLUDE_DIR include)
4146
if(PROXY_BUILD_MODULES)
42-
include(cmake/proxyModuleTargets.cmake)
47+
include(cmake/proxy4ModuleTargets.cmake)
4348
endif()
4449
else()
4550
# Propagate the variable to the parent project
46-
set(proxy_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
51+
set(proxy4_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include PARENT_SCOPE)
4752
endif()
4853

4954
# install and export the project. project name - proxy
5055

5156
include(GNUInstallDirs)
5257

53-
install(TARGETS msft_proxy
54-
EXPORT proxyTargets
58+
install(TARGETS msft_proxy4
59+
EXPORT proxy4Targets
5560
FILE_SET public_headers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
5661
)
5762

58-
install(EXPORT proxyTargets DESTINATION ${CMAKE_INSTALL_DATADIR}/proxy)
59-
export(TARGETS msft_proxy FILE proxyTargets.cmake)
63+
install(
64+
EXPORT proxy4Targets
65+
NAMESPACE msft_proxy::
66+
DESTINATION ${CMAKE_INSTALL_DATADIR}/proxy
67+
)
68+
export(
69+
TARGETS msft_proxy4
70+
NAMESPACE msft_proxy::
71+
FILE proxy4Targets.cmake
72+
)
6073

6174
include(CMakePackageConfigHelpers)
6275
configure_package_config_file(
63-
cmake/proxyConfig.cmake.in
64-
${CMAKE_CURRENT_BINARY_DIR}/cmake/proxyConfig.cmake
76+
cmake/proxy4Config.cmake.in
77+
${CMAKE_CURRENT_BINARY_DIR}/cmake/proxy4Config.cmake
6578
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/proxy
6679
PATH_VARS CMAKE_INSTALL_INCLUDEDIR
6780
)
6881

6982
include(CMakePackageConfigHelpers)
70-
write_basic_package_version_file(cmake/proxyConfigVersion.cmake
83+
write_basic_package_version_file(cmake/proxy4ConfigVersion.cmake
7184
COMPATIBILITY SameMajorVersion
7285
ARCH_INDEPENDENT)
7386

7487
install(
7588
FILES
76-
${CMAKE_CURRENT_BINARY_DIR}/cmake/proxyConfig.cmake
77-
${CMAKE_CURRENT_BINARY_DIR}/cmake/proxyConfigVersion.cmake
89+
${CMAKE_CURRENT_BINARY_DIR}/cmake/proxy4Config.cmake
90+
${CMAKE_CURRENT_BINARY_DIR}/cmake/proxy4ConfigVersion.cmake
7891
DESTINATION ${CMAKE_INSTALL_DATADIR}/proxy
7992
)
8093

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ Please refer to the [Proxy's Frequently Asked Questions](https://microsoft.githu
3535

3636
```cmake
3737
CPMAddPackage(
38-
NAME proxy
38+
NAME proxy4
3939
GIT_TAG 4.0.0 # or above
4040
GIT_REPOSITORY https://github.com/microsoft/proxy.git
4141
)
4242
43-
target_link_libraries(main PRIVATE msft_proxy)
43+
target_link_libraries(main PRIVATE msft_proxy::proxy4)
4444
```
4545
4646
### Hello World

benchmarks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ add_executable(msft_proxy_benchmarks
2222
proxy_management_benchmark.cpp
2323
)
2424
target_include_directories(msft_proxy_benchmarks PRIVATE .)
25-
target_link_libraries(msft_proxy_benchmarks PRIVATE msft_proxy benchmark::benchmark benchmark::benchmark_main)
25+
target_link_libraries(msft_proxy_benchmarks PRIVATE msft_proxy::proxy4 benchmark::benchmark benchmark::benchmark_main)
2626

2727
if (MSVC)
2828
target_compile_options(msft_proxy_benchmarks PRIVATE /W4)

cmake/proxy4Config.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@PACKAGE_INIT@
2+
3+
include("${CMAKE_CURRENT_LIST_DIR}/proxy4Targets.cmake")
4+
5+
set(proxy4_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")

cmake/proxy4ModuleTargets.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
if(NOT DEFINED proxy4_INCLUDE_DIR)
3+
message(FATAL_ERROR "proxy4_INCLUDE_DIR must be defined to use this script.")
4+
endif()
5+
6+
message(STATUS "Declaring `msft_proxy::proxy4_module` target for include path ${proxy4_INCLUDE_DIR}")
7+
8+
add_library(msft_proxy4_module)
9+
set_target_properties(
10+
msft_proxy4_module
11+
PROPERTIES
12+
SYSTEM TRUE
13+
EXCLUDE_FROM_ALL TRUE
14+
)
15+
16+
add_library(msft_proxy::proxy4_module ALIAS msft_proxy4_module)
17+
target_sources(msft_proxy4_module PUBLIC
18+
FILE_SET CXX_MODULES
19+
BASE_DIRS ${proxy4_INCLUDE_DIR}
20+
FILES
21+
${proxy4_INCLUDE_DIR}/proxy/v4/proxy.ixx
22+
)
23+
target_compile_features(msft_proxy4_module PUBLIC cxx_std_20)
24+
target_link_libraries(msft_proxy4_module PUBLIC msft_proxy::proxy4)
25+

cmake/proxyConfig.cmake.in

Lines changed: 0 additions & 5 deletions
This file was deleted.

cmake/proxyModuleTargets.cmake

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set_source_files_properties(${EXAMPLE_SOURCES} PROPERTIES GENERATED TRUE)
1717
foreach(SOURCE ${EXAMPLE_SOURCES})
1818
get_filename_component(EXECUTABLE_NAME ${SOURCE} NAME_WE)
1919
add_executable(${EXECUTABLE_NAME} ${SOURCE})
20-
target_link_libraries(${EXECUTABLE_NAME} PRIVATE msft_proxy)
20+
target_link_libraries(${EXECUTABLE_NAME} PRIVATE msft_proxy::proxy4)
2121
if (MSVC)
2222
target_compile_options(${EXECUTABLE_NAME} PRIVATE /W4)
2323
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

docs/cpp20_modules_support.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,43 @@ The "Proxy" library ships with `.ixx` files starting with version **4.0.0**. Com
55
As of 2025-05-11, CMake lacks support for forward compatibility when consuming C++ modules, which causes consumers with newer C++ standard to be unable to use modules with older standard. Until this is implemented by CMake, a CMake target containing the module can be manually declared using the following CMake script:
66

77
```cmake
8-
find_package(proxy REQUIRED)
8+
find_package(proxy4 REQUIRED)
99
10-
if(NOT DEFINED proxy_INCLUDE_DIR) # (1)
10+
if(NOT DEFINED proxy4_INCLUDE_DIR) # (1)
1111
if(NOT DEFINED proxy_SOURCE_DIR)
12-
message(FATAL_ERROR "proxy_INCLUDE_DIR or proxy_SOURCE_DIR must be defined to use this script.")
12+
message(FATAL_ERROR "proxy4_INCLUDE_DIR or proxy_SOURCE_DIR must be defined to use this script.")
1313
endif()
14-
set(proxy_INCLUDE_DIR ${proxy_SOURCE_DIR}/include)
14+
set(proxy4_INCLUDE_DIR ${proxy_SOURCE_DIR}/include)
1515
endif()
1616
17-
message(STATUS "Declaring `msft_proxy::module` target for include path ${proxy_INCLUDE_DIR}")
17+
message(STATUS "Declaring `msft_proxy::proxy4_module` target for include path ${proxy4_INCLUDE_DIR}")
1818
19-
add_library(msft_proxy_module)
19+
add_library(msft_proxy4_module)
2020
set_target_properties(
21-
msft_proxy_module
21+
msft_proxy4_module
2222
PROPERTIES
2323
SYSTEM TRUE
2424
EXCLUDE_FROM_ALL TRUE
2525
)
2626
27-
add_library(msft_proxy::module ALIAS msft_proxy_module)
28-
target_sources(msft_proxy_module PUBLIC
27+
add_library(msft_proxy::proxy4_module ALIAS msft_proxy4_module)
28+
target_sources(msft_proxy4_module PUBLIC
2929
FILE_SET CXX_MODULES
30-
BASE_DIRS ${proxy_INCLUDE_DIR}
30+
BASE_DIRS ${proxy4_INCLUDE_DIR}
3131
FILES
32-
${proxy_INCLUDE_DIR}/proxy/proxy.ixx
32+
${proxy4_INCLUDE_DIR}/proxy/v4/proxy.ixx
3333
)
34-
target_compile_features(msft_proxy_module PUBLIC cxx_std_20) # (2)
35-
target_link_libraries(msft_proxy_module PUBLIC msft_proxy)
34+
target_compile_features(msft_proxy4_module PUBLIC cxx_std_20) # (2)
35+
target_link_libraries(msft_proxy4_module PUBLIC msft_proxy::proxy4)
3636
```
3737

38-
- (1) `proxy_INCLUDE_DIR` is automatically declared after `find_package(proxy)`. CPM uses a slightly different convention where `proxy_SOURCE_DIR` is declared after `CPMAddPackage`.
39-
- (2) The C++ standard version for `msft_proxy_module` target should be the same or higher than the consumer CMake target. For example if your project is using C++23 mode, this line should be changed to `cxx_std_23` or `cxx_std_26` / newer standards.
38+
- (1) `proxy4_INCLUDE_DIR` is automatically declared after `find_package(proxy4)`. CPM uses a slightly different convention where `proxy_SOURCE_DIR` is declared after `CPMAddPackage`.
39+
- (2) The C++ standard version for `msft_proxy4_module` target should be the same or higher than the consumer CMake target. For example if your project is using C++23 mode, this line should be changed to `cxx_std_23` or `cxx_std_26` / newer standards.
4040

4141
It can then be consumed like this:
4242

4343
```cmake
44-
target_link_libraries(main PRIVATE msft_proxy::module)
44+
target_link_libraries(main PRIVATE msft_proxy::proxy4_module)
4545
```
4646

4747
## Example
@@ -58,7 +58,7 @@ module;
5858

5959
export module dictionary;
6060

61-
import proxy; // (3)
61+
import proxy.v4; // (3)
6262

6363
extern "C++" { // (4)
6464
PRO_DEF_MEM_DISPATCH(MemAt, at);
@@ -77,7 +77,7 @@ Client:
7777
#include <vector>
7878
#include <iostream>
7979
80-
import proxy;
80+
import proxy.v4;
8181
import dictionary;
8282
8383
int main() {
@@ -90,6 +90,6 @@ int main() {
9090

9191
- (1) This is a traditional header rather than a module. It should be declared in global fragment (after `module` and before `export module`).
9292
- (2) This makes all `PRO_DEF_` macros available. This header file contains only some macros and are therefore very fast to compile.
93-
- (3) `import proxy;` makes all public interfaces from `pro` namespace available in the current translation unit.
93+
- (3) `import proxy.v4;` makes all public interfaces from `pro::v4` namespace available in the current translation unit.
9494
- (4) As of 2025-05-11, clangd requires the accessor struct to be either `export`-ed, or be declared within an `extern "C++"` block, in order to have auto completion working.
9595

0 commit comments

Comments
 (0)