Skip to content

Commit 366bb38

Browse files
committed
Removed hpx_auto_wrap.cpp and included HPX_AUTO_WRAP_MAIN_ACTIVATE functionality in the hpx_wrap.cpp which is defined to the target the with the help of target_compile_definitions in the CMakelists.txt file
Signed-off-by: Bharath <bharath.kollanur@gmail.com>
1 parent f42d6e8 commit 366bb38

5 files changed

Lines changed: 31 additions & 175 deletions

File tree

libs/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ target_link_libraries(
186186
)
187187
add_library(hpx_interface_auto_wrap_main INTERFACE)
188188
target_link_libraries(
189-
hpx_interface_auto_wrap_main INTERFACE $<${_is_executable}:HPXInternal::hpx_auto_wrap>
189+
hpx_interface_auto_wrap_main
190+
INTERFACE $<${_is_executable}:HPXInternal::hpx_auto_wrap>
190191
)
191192

192193
target_link_libraries(wrap_main INTERFACE hpx_interface_wrap_main)
@@ -219,7 +220,9 @@ target_compile_definitions(
219220
)
220221

221222
set(hpx_targets hpx wrap_main auto_wrap_main init plugin component)
222-
set(hpx_internal_targets hpx_full hpx_interface hpx_interface_wrap_main hpx_interface_auto_wrap_main)
223+
set(hpx_internal_targets hpx_full hpx_interface hpx_interface_wrap_main
224+
hpx_interface_auto_wrap_main
225+
)
223226

224227
# cmake-format: off
225228
install(

tests/unit/init/auto_wrap_main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
#include <hpx/modules/testing.hpp>
99
#include <hpx/runtime_local/runtime_local.hpp>
1010

11-
int main(int, char**) {
11+
int main(int, char**)
12+
{
1213
// The wrapper should have initialized HPX runtime before reaching main.
1314
HPX_TEST(hpx::get_runtime_ptr() != nullptr);
1415

15-
// Verify that calling thread is an HPX thread by launching another
16+
// Verify that calling thread is an HPX thread by launching another
1617
// HPX task and waiting for its result.
17-
auto f = hpx::async([] { return (hpx::get_runtime_ptr() != nullptr);});
18+
auto f = hpx::async([] { return (hpx::get_runtime_ptr() != nullptr); });
1819
HPX_TEST(f.get());
1920

2021
return hpx::util::report_errors();
21-
2222
}

wrap/CMakeLists.txt

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,15 @@ set(hpx_wrap_SOURCES
2020
)
2121
list(APPEND hpx_wrap_SOURCES hpx_wrap.cpp hpx_main.cpp)
2222

23-
set(hpx_auto_wrap_SOURCES
24-
""
25-
CACHE INTERNAL "Sources for libhpx_auto_wrap." FORCE
26-
)
27-
list(APPEND hpx_auto_wrap_SOURCES hpx_auto_wrap.cpp hpx_main.cpp)
28-
2923
# make source groups
3024
set(hpx_wrap_SOURCE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src)
3125
list(TRANSFORM hpx_wrap_SOURCES PREPEND ${hpx_wrap_SOURCE_ROOT}/)
32-
list(TRANSFORM hpx_auto_wrap_SOURCES PREPEND ${hpx_wrap_SOURCE_ROOT}/)
3326
add_hpx_source_group(
3427
NAME hpx_wrap
3528
CLASS "Source Files"
3629
ROOT "${hpx_wrap_SOURCE_ROOT}"
3730
TARGETS ${hpx_wrap_SOURCES}
3831
)
39-
add_hpx_source_group(
40-
NAME hpx_auto_wrap
41-
CLASS "Source Files"
42-
ROOT "${hpx_wrap_SOURCE_ROOT}"
43-
TARGETS ${hpx_auto_wrap_SOURCES}
44-
)
4532

4633
set(hpx_wrap_HEADER_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/include)
4734
list(TRANSFORM hpx_wrap_HEADERS PREPEND ${hpx_wrap_HEADER_ROOT}/)
@@ -51,18 +38,12 @@ add_hpx_source_group(
5138
ROOT "${hpx_wrap_HEADER_ROOT}"
5239
TARGETS ${hpx_wrap_HEADERS}
5340
)
54-
add_hpx_source_group(
55-
NAME hpx_auto_wrap
56-
CLASS "Header Files"
57-
ROOT "${hpx_wrap_HEADER_ROOT}"
58-
TARGETS ${hpx_wrap_HEADERS}
59-
)
6041

6142
add_library(
6243
hpx_wrap STATIC ${hpx_wrap_SOURCES} ${hpx_wrap_HEADERS} ${config_header}
6344
)
6445
add_library(
65-
hpx_auto_wrap STATIC ${hpx_auto_wrap_SOURCES} ${hpx_wrap_HEADERS} ${config_header}
46+
hpx_auto_wrap STATIC ${hpx_wrap_SOURCES} ${hpx_wrap_HEADERS} ${config_header}
6647
)
6748

6849
set_target_properties(hpx_wrap PROPERTIES POSITION_INDEPENDENT_CODE ON)
@@ -79,10 +60,12 @@ set_target_properties(hpx_auto_wrap PROPERTIES POSITION_INDEPENDENT_CODE ON)
7960
target_link_libraries(hpx_auto_wrap PRIVATE hpx_full)
8061
target_link_libraries(hpx_auto_wrap PRIVATE hpx_init)
8162
target_link_libraries(hpx_auto_wrap PRIVATE hpx_private_flags)
82-
target_compile_definitions(hpx_auto_wrap PRIVATE HPX_LIBRARY_EXPORTS)
63+
target_compile_definitions(
64+
hpx_auto_wrap PRIVATE HPX_LIBRARY_EXPORTS HPX_AUTO_WRAP_MAIN_ACTIVATE
65+
)
8366
target_include_directories(
8467
hpx_auto_wrap PUBLIC $<BUILD_INTERFACE:${hpx_wrap_HEADER_ROOT}>
85-
$<INSTALL_INTERFACE:include>
68+
$<INSTALL_INTERFACE:include>
8669
)
8770

8871
if(HPX_WITH_CXX_MODULES)

wrap/src/hpx_auto_wrap.cpp

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

wrap/src/hpx_wrap.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66

77
#include <hpx/config.hpp>
8+
#include <hpx/hpx_init.hpp>
89

910
// The following implementation has been divided for Linux and Mac OSX
1011
#if defined(HPX_HAVE_DYNAMIC_HPX_MAIN) && \
@@ -17,14 +18,27 @@ namespace hpx_start {
1718
// include_libhpx_wrap is a weak symbol which helps to determine the course
1819
// of function calls at runtime. It has a default value of `false` which
1920
// corresponds to the program's entry point being main().
20-
// It is overridden in hpx/hpx_main.hpp. Thus, inclusion of the header file
21+
// It is overridden in hpx/hpx_main.hpp or set as TRUE if HPX_AUTO_WRAP_MAIN_ACTIVATE is defined.
22+
// Thus, inclusion of the header file or defining HPX_AUTO_WRAP_MAIN_ACTIVATE
2123
// will change the program's entry point to HPX's own custom entry point
2224
// initialize_main. Subsequent calls before entering main() are handled
2325
// by this code.
2426
HPX_SYMBOL_EXPORT extern bool include_libhpx_wrap;
25-
HPX_SYMBOL_EXPORT bool include_libhpx_wrap __attribute__((weak)) = false;
27+
HPX_SYMBOL_EXPORT bool include_libhpx_wrap __attribute__((weak)) =
28+
#if defined(HPX_AUTO_WRAP_MAIN_ACTIVATE)
29+
true;
30+
#else
31+
false;
32+
#endif
33+
// The default application name is populated by including hpx/hpx_main.hpp
34+
// or if HPX_AUTO_WRAP_MAIN_ACTIVATE is defined.
2635
HPX_SYMBOL_EXPORT extern const char* app_name_libhpx_wrap;
27-
HPX_SYMBOL_EXPORT const char* app_name_libhpx_wrap __attribute__((weak));
36+
HPX_SYMBOL_EXPORT const char* app_name_libhpx_wrap __attribute__((weak)) =
37+
#if defined(HPX_AUTO_WRAP_MAIN_ACTIVATE)
38+
HPX_APPLICATION_STRING;
39+
#else
40+
nullptr;
41+
#endif
2842

2943
// Provide a definition of is_linked variable defined weak in hpx_main.hpp
3044
// header. This variable is solely to trigger a different exception when
@@ -34,7 +48,6 @@ namespace hpx_start {
3448
} // namespace hpx_start
3549

3650
#include <hpx/hpx_finalize.hpp>
37-
#include <hpx/hpx_init.hpp>
3851
#include <hpx/modules/functional.hpp>
3952
#include <hpx/modules/runtime_configuration.hpp>
4053

0 commit comments

Comments
 (0)