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

Check for nullptr when getting appdata_path #884

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
52 changes: 52 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

# Generated by `boostdep --cmake compute`
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt

cmake_minimum_required(VERSION 3.5...3.20)

project(boost_compute VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

add_library(boost_compute INTERFACE)
add_library(Boost::compute ALIAS boost_compute)

target_include_directories(boost_compute INTERFACE include)

target_link_libraries(boost_compute
INTERFACE
Boost::algorithm
Boost::array
Boost::assert
Boost::atomic
Boost::chrono
Boost::config
Boost::core
Boost::filesystem
Boost::function
Boost::function_types
Boost::fusion
Boost::iterator
Boost::lexical_cast
Boost::mpl
Boost::optional
Boost::preprocessor
Boost::property_tree
Boost::proto
Boost::range
Boost::smart_ptr
Boost::static_assert
Boost::thread
Boost::throw_exception
Boost::tuple
Boost::type_traits
Boost::typeof
Boost::utility
Boost::uuid
)

else()

# ---------------------------------------------------------------------------
# Copyright (c) 2013 Kyle Lutz <[email protected]>
#
Expand Down Expand Up @@ -127,3 +177,5 @@ install(

# install header files
install(DIRECTORY include/boost DESTINATION include/compute)

endif()
15 changes: 11 additions & 4 deletions include/boost/compute/detail/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ static const std::string& path_delim()
// Path to appdata folder.
inline const std::string& appdata_path()
{
const char *user_path;
#ifdef _WIN32
static const std::string appdata = detail::getenv("APPDATA")
+ path_delim() + "boost_compute";
user_path = detail::getenv("APPDATA");
if (user_path == nullptr) {
std::cerr << "ERROR: Unable to find APPDATA environment variable." << std::endl;
}
#else
static const std::string appdata = detail::getenv("HOME")
+ path_delim() + ".boost_compute";
user_path = detail::getenv("HOME");
if (user_path == nullptr) {
std::cerr << "ERROR: Unable to find HOME environment variable." << std::endl;
}
#endif
static const std::string appdata = user_path
+ path_delim() + ".boost_compute";
return appdata;
}

Expand Down