Skip to content

Commit

Permalink
config var test
Browse files Browse the repository at this point in the history
  • Loading branch information
ctaylor committed May 2, 2023
1 parent 52f6bb8 commit d57361c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
48 changes: 48 additions & 0 deletions backend/test/cfg/CMakeLists.txt.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# This program file was generated by the chplx compiler.
# The original Chapel program file can be found here: "cfg.chpl"
#
cmake_minimum_required(VERSION 3.19)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Configuration type" FORCE)
endif()
project(cfg)
add_executable(cfg cfg.cpp)
if(NOT APPLE)
set(CMAKE_CXX_STANDARD 20)
endif()
if(NOT WIN32 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND NOT APPLE)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -stdlib=libc++)
endif()
if(NOT Chplx_DIR)
message(FATAL_ERROR "Chplx_DIR variable undefined")
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
find_package(fmt REQUIRED CONFIG)
find_package(HPX REQUIRED CONFIG)
find_package(Chplx REQUIRED CONFIG)
set(cfg_sources cfg.cpp)
set(cfg_headers cfg.hpp)
if(NOT WIN32 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND APPLE)
find_library(CORE_LIBPATH NAMES CoreFoundation REQUIRED)
target_compile_options(cfg
PUBLIC
-nostdlib
-std=c++20
-O3
-stdlib=libc++
)
target_link_libraries(cfg PRIVATE ${CORE_LIBPATH})
target_link_libraries(cfg
PUBLIC
c++
)
endif()
target_link_libraries(cfg PUBLIC fmt::fmt-header-only HPX::hpx Chplx::library)
enable_testing()
include(CTest)
add_test(
NAME cfg_test
COMMAND cfg
WORKING_DIRECTORY $<TARGET_FILE_DIR:cfg>
)
33 changes: 33 additions & 0 deletions backend/test/cfg/cfg.cpp.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This program file was generated by the chplx compiler.
// The original Chapel program file can be found here: cfg.chpl
//
#include <hpx/hpx_init.hpp>

#include "cfg.hpp"

// global `config` variables
//
std::int64_t config_a;
std::int64_t config_b = 1;

int hpx_main(int argc, char * argv[]) {

#line 1 "../../backend/test/cfg.chpl"
const std::int64_t a = config_a;
#line 2 "../../backend/test/cfg.chpl"
std::int64_t b = config_b;

return hpx::finalize();
}

int main(int argc, char * argv[]) {
hpx::program::options::options::options_description options;
options.add_options()
("a",
hpx::program_options::value<std::int64_t>(&config_a), "config var a : std::int64_t")
("b",
hpx::program_options::value<std::int64_t>(&config_b), "config var b : std::int64_t");
hpx::init_params init_args;
init_args.desc_cmdline = options;
return hpx::init(argc, argv, init_args);
}
11 changes: 11 additions & 0 deletions backend/test/cfg/cfg.hpp.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This program file was generated by the chplx compiler.
// The original Chapel program file can be found here: "cfg.chpl"
//
#pragma once

#ifndef __CFG_HPP__
#define __CFG_HPP__

#include <chplx.hpp>

#endif

0 comments on commit d57361c

Please sign in to comment.