Skip to content

Commit

Permalink
[launch-app] Fix mac build
Browse files Browse the repository at this point in the history
  • Loading branch information
gamingdoom committed Feb 29, 2024
1 parent 2181625 commit 5685dcd
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/launch-app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(launch-app)

file(GLOB_RECURSE sources src/*.cpp src/*.hpp)

set( BOOST_INCLUDE_LIBRARIES dll interprocess process algorithm )
set( BOOST_INCLUDE_LIBRARIES dll interprocess process algorithm thread )

if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_subdirectory(extern/boost/ EXCLUDE_FROM_ALL)
Expand All @@ -18,7 +18,7 @@ endif()

add_executable(launch-app ${sources} ${Boost_INCLUDE_DIRS} ${RES_PATH})

target_compile_options(launch-app PRIVATE -std=c++17 -Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -g)
target_compile_options(launch-app PRIVATE -std=c++17 -Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -O2)

target_compile_definitions(launch-app PRIVATE APPLICATION_NAME=${APPLICATION_NAME} SHOULD_OPEN_IN_DEFAULT_BROWSER=${SHOULD_OPEN_IN_DEFAULT_BROWSER} SHOULD_RUN_IN_BACKGROUND=${SHOULD_RUN_IN_BACKGROUND})

Expand All @@ -30,10 +30,10 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
)
else()
target_link_libraries(launch-app PRIVATE
${MY_BOOST_LIB_PATHS}
${BOOST_SYSTEM_LIB}
${BOOST_THREAD_LIB}
)
target_include_directories(launch-app PRIVATE
${MY_BOOST_INCLUDE_DIRS}
extern/traypp/tray/include
)
endif()
1 change: 0 additions & 1 deletion src/launch-app/src/mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "platform_specific.hpp"
#include "placeholders.hpp"
#include "tray.hpp"

#define OPEN_IN_DEFAULT_BROWSER_PATH "/tmp/open-in-default-browser"

Expand Down
4 changes: 3 additions & 1 deletion src/launch-app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ int main(int argc, char *argv[]) {
std::thread *tray_runner;
if (SHOULD_RUN_IN_BACKGROUND){
tray = platform_specific::setup_tray(appDir, instance_guard, window_state, should_exit);
tray_runner = new std::thread([&]{tray->run();});
#ifndef __APPLE__
tray_runner = new std::thread([&]{tray->run();});
#endif
}


Expand Down
4 changes: 4 additions & 0 deletions src/launch-app/src/platform_specific.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#pragma once

#include "running_guard.hpp"
#if defined(__APPLE__)
#include "tray_mac.hpp"
#else
#include "tray.hpp"
#endif

#include <filesystem>

Expand Down
9 changes: 9 additions & 0 deletions src/launch-app/src/tray_mac.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <cstdio>
namespace Tray{
class Tray {
public:
void run(){};
void update(){};
void exit(){};
};
}
6 changes: 4 additions & 2 deletions src/scripts/build/launch-app-mac-arm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export MACOSX_DEPLOYMENT_TARGET=10.15
PATH="$(realpath target/bin):${PATH}"
UNATTENDED=1 MACOSX_DEPLOYMENT_TARGET=11.3 osxcross-macports install boost181
echo $(MACOSX_DEPLOYMENT_TARGET=11.3 osxcross-macports --ldflags boost181)
boostLibPaths="$(realpath ../../../osxcross/target/macports/pkgs/opt/local/libexec/boost/1.81/lib/libboost_system-mt.dylib)"
boost_system_path="$(realpath target/macports/pkgs/opt/local/libexec/boost/1.81/lib/libboost_system-mt.dylib)"
boost_thread_path="$(realpath target/macports/pkgs/opt/local/libexec/boost/1.81/lib/libboost_thread-mt.dylib)"
cd ..

rm -rf src/launch-app/build
Expand All @@ -21,7 +22,8 @@ pushd src/launch-app/build
-DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DCMAKE_SIZEOF_VOID_P=8 \
-DCMAKE_SYSTEM_NAME=Darwin \
-DMY_BOOST_LIB_PATHS=$boostLibPaths \
-DBOOST_SYSTEM_LIB="${boost_system_path}" \
-DBOOST_THREAD_LIB="${boost_thread_path}" \
-DMY_BOOST_INCLUDE_DIRS=$(realpath ../../../osxcross/target/macports/pkgs/opt/local/libexec/boost/1.81/include/) \
.. \
-DAPPLICATION_NAME=\"NEUTRON_INTERNAL_APP_NAME\" \
Expand Down
6 changes: 4 additions & 2 deletions src/scripts/build/launch-app-mac-intel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ UNATTENDED=1 ./build.sh
PATH="$(realpath target/bin):${PATH}"
UNATTENDED=1 MACOSX_DEPLOYMENT_TARGET=11.3 osxcross-macports install boost181
echo $(MACOSX_DEPLOYMENT_TARGET=11.3 osxcross-macports --ldflags boost181)
boostLibPaths="$(realpath ../../../osxcross/target/macports/pkgs/opt/local/libexec/boost/1.81/lib/libboost_system-mt.dylib)"
boost_system_path="$(realpath target/macports/pkgs/opt/local/libexec/boost/1.81/lib/libboost_system-mt.dylib)"
boost_thread_path="$(realpath target/macports/pkgs/opt/local/libexec/boost/1.81/lib/libboost_thread-mt.dylib)"
cd ..

rm -rf src/launch-app/build
Expand All @@ -21,7 +22,8 @@ pushd src/launch-app/build
-DCMAKE_SYSTEM_PROCESSOR=x86_64 \
-DCMAKE_SIZEOF_VOID_P=8 \
-DCMAKE_SYSTEM_NAME=Darwin \
-DMY_BOOST_LIB_PATHS=$boostLibPaths \
-DBOOST_SYSTEM_LIB="${boost_system_path}" \
-DBOOST_THREAD_LIB="${boost_thread_path}" \
-DMY_BOOST_INCLUDE_DIRS=$(realpath ../../../osxcross/target/macports/pkgs/opt/local/libexec/boost/1.81/include/) \
.. \
-DAPPLICATION_NAME=\"NEUTRON_INTERNAL_APP_NAME\" \
Expand Down

0 comments on commit 5685dcd

Please sign in to comment.