Skip to content

Commit

Permalink
win32.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
rehdi93 committed Feb 27, 2019
1 parent 012e7bd commit ea8aa8b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
cmake_minimum_required(VERSION 3.10)
project(sessions)

set(INC_DIR ${PROJECT_SOURCE_DIR}/include/red)
set(HEADERS ${INC_DIR}/session.hpp ${INC_DIR}/session_impl.hpp ${INC_DIR}/session_envcache.hpp src/impl.hpp)
set(HEADERS include/red/session.hpp include/red/session_impl.hpp include/red/session_envcache.hpp src/impl.hpp)
if(WIN32)
set(HEADERS ${HEADERS} src/win32.hpp)
endif()

add_library(sessions ${HEADERS} src/session.cpp)

target_include_directories(sessions PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_compile_features(sessions PUBLIC cxx_std_17)
add_library(sessions ${HEADERS} src/session.cpp)
target_sources(sessions PRIVATE
$<$<NOT:$<PLATFORM_ID:Windows>>:src/posix.cxx>
$<$<PLATFORM_ID:Windows>:src/windows.cxx>
)
target_include_directories(sessions PUBLIC include)
target_compile_features(sessions PUBLIC cxx_std_17)

# tests
add_executable(tests test/test.cpp test/util.cpp)
target_link_libraries(tests PRIVATE sessions)
target_include_directories(tests PRIVATE src)

if(MSVC)
if(WIN32)
add_compile_definitions(UNICODE _UNICODE)
endif()
4 changes: 2 additions & 2 deletions test/slimwindows.h → src/win32.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

// slimwindows.h - windows.h + all defines
// win32.hpp - windows.h + all defines
// ---------------------------------------------------------------------------

// If defined, the following flags inhibit definition of the indicated items.
Expand Down Expand Up @@ -47,7 +47,7 @@

#define NOUSER // - All USER defines and routines

#define NONLS // - All NLS defines and routines
// #define NONLS // - All NLS defines and routines

#define NOMB // - MB_* and MessageBox()

Expand Down
10 changes: 5 additions & 5 deletions src/windows.cxx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>

#include "win32.hpp"
#include <shellapi.h>

#include <algorithm>
Expand All @@ -17,9 +16,10 @@
#include "red/session_impl.hpp"
#include "red/session_envcache.hpp"

namespace {
using namespace red::session::detail;

using namespace red::session::detail;

namespace {

[[noreturn]]
void throw_win_error(DWORD error = GetLastError())
Expand Down
3 changes: 1 addition & 2 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "catch.hpp"

#if defined(WIN32)
#include "slimwindows.h"
#include "win32.hpp"
#endif // WIN32


Expand Down Expand Up @@ -65,7 +65,6 @@ TEST_CASE("Environment tests", "[environment]")
for(auto c : cases)
{
auto it = env.find(c.first);
INFO(*it);
CHECK(it != env.end());
}

Expand Down

0 comments on commit ea8aa8b

Please sign in to comment.