Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/hadouken/hadouken into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
Kyle Sabo committed Feb 7, 2016
2 parents 2a70cc4 + 9618804 commit 32ba876
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 19 deletions.
62 changes: 44 additions & 18 deletions CMakeLists.txt
Expand Up @@ -11,6 +11,12 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Windows DLLs are "runtime" for CMake. Output them to "bin" like the Visual Studio projects do.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Options used for *nix platforms to make boost link statically

option(Boost_USE_STATIC_LIBS "Static linking to boost libraries" ON)
option(Boost_USE_STATIC_RUNTIME "Static runtime" ON)


if(WIN32)
set(LIBSSL libeay32.lib ssleay32.lib)
set(LIBEXTRAS iphlpapi.lib dbghelp.lib shlwapi.lib)
Expand Down Expand Up @@ -47,15 +53,17 @@ if(WIN32)
# Make sure release builds have pdb files.
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF")
elseif(APPLE)

# Some libraries installed via homebrew or macports are installed in these paths

include_directories(/usr/local/include)
link_directories(/usr/local/lib)

else()
set(LIBBOOST libboost_system.a libboost_log.a libboost_program_options.a libboost_filesystem.a libboost_thread.a)

set(LIBEXTRAS rt)
set(LIBSSL ssl crypto)
set(LIBTORRENT libtorrent-rasterbar.a)
set(PTHREAD pthread)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

if(DEFINED ENV{TRAVIS})
# Disable deprecated warnings (for auto_ptr mainly) on travis
# since there are so many and travis cuts our log output after
Expand All @@ -64,6 +72,23 @@ else()
endif()
endif()

if(UNIX)
find_package(Boost REQUIRED COMPONENTS system program_options filesystem log thread)

set(LIBSSL ssl crypto)
set(PTHREAD pthread)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

include_directories(${CMAKE_SOURCE_DIR}/deps/libtorrent/include)

include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

set(LIBBOOST ${Boost_LIBRARIES})

endif()

include_directories(
${CMAKE_SOURCE_DIR}/deps/cpp-netlib
)
Expand Down Expand Up @@ -229,18 +254,17 @@ set(ed25519_sources
verify
)

if(WIN32)
foreach(s ${sources})
list(APPEND LIBTORRENT_SOURCES ${ltdir}/src/${s})
endforeach(s)

foreach(s ${kademlia_sources})
list(APPEND LIBTORRENT_SOURCES ${ltdir}/src/kademlia/${s})
endforeach(s)
foreach(s ${ed25519_sources})
list(APPEND LIBTORRENT_SOURCES ${ltdir}/ed25519/src/${s})
endforeach(s)
endif(WIN32)
foreach(s ${sources})
list(APPEND LIBTORRENT_SOURCES ${ltdir}/src/${s})
endforeach(s)

foreach(s ${kademlia_sources})
list(APPEND LIBTORRENT_SOURCES ${ltdir}/src/kademlia/${s})
endforeach(s)

foreach(s ${ed25519_sources})
list(APPEND LIBTORRENT_SOURCES ${ltdir}/ed25519/src/${s})
endforeach(s)


set(HADOUKEN_SOURCES
Expand Down Expand Up @@ -282,6 +306,8 @@ set(HADOUKEN_SOURCES
# Append platform-specific sources
if(WIN32)
list(APPEND HADOUKEN_SOURCES src/platform_win32 src/hosting/service_host)
elseif(APPLE)
list(APPEND HADOUKEN_SOURCES src/platform_osx)
else()
list(APPEND HADOUKEN_SOURCES src/platform_unix)
endif(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion linux/build.sh
Expand Up @@ -19,4 +19,4 @@ export LIBRARY_PATH=$LIBRARY_PATH:$HOME/libtorrent/lib
( cp -R ../js build/bin/ )

# Build and package Hadouken
( mkdir -p build ; cd build ; cmake ../../ ; make ; make package )
( mkdir -p build ; cd build ; cmake ../../ -DBOOST_ROOT=$HOME/boost ; make ; make package )
54 changes: 54 additions & 0 deletions src/platform_osx.cpp
@@ -0,0 +1,54 @@
#ifdef __APPLE__

#include <boost/filesystem.hpp>
#include <hadouken/platform.hpp>

#include <cstdlib>
#include <mach-o/dyld.h>

using namespace hadouken;
namespace fs = boost::filesystem;

void platform::init() {}

fs::path platform::data_path()
{
// TODO: find folders using URLsForDirectory

char *home_path = getenv("HOME");

if(home_path != nullptr)
{
std::string p(home_path);
p += "/Downloads";
return fs::path(p);
}

return "";
}

fs::path platform::application_path()
{
char path[2048];
uint32_t size = sizeof(path);

if (_NSGetExecutablePath(path, &size) == 0)
{
return fs::path(path).parent_path();
}

return "";
}

fs::path platform::get_current_directory()
{
return fs::initial_path();
}

int platform::launch_process(std::string executable,
std::vector<std::string> args)
{
return 0;
}

#endif

0 comments on commit 32ba876

Please sign in to comment.