diff --git a/.travis.yml b/.travis.yml index dbb42f1..0ad1b4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,3 +46,28 @@ matrix: - cd anypiab/build - cmake .. - make + - name: "emscripten-anypiab-mac" + os: osx + osx_image: xcode11.4 + addons: + homebrew: + packages: + - cmake + - boost + - emscripten + script: + # Needed to use Homebrew's emscripten + - export LLVM=/usr/local/opt/emscripten/libexec/llvm/bin + - export BINARYEN=/usr/local/opt/binaryen + - wget -q "https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.zip" + - unzip -q boost_1_64_0.zip + - cd boost_1_64_0 + - ./bootstrap.sh + - ./b2 toolset=emscripten link=static runtime-link=static --with-date_time + - export BOOST_INCL=`pwd` + - export BOOST_LIB=`pwd`/stage/lib + - cd .. + - mkdir anypiab/build + - cd anypiab/build + - emcmake cmake -DBOOST_INCLUDEDIR=$BOOST_INCL -DBOOST_LIBRARYDIR=$BOOST_LIB .. + - make -j2 diff --git a/anypiab/CMakeLists.txt b/anypiab/CMakeLists.txt index 4440e93..c26c031 100644 --- a/anypiab/CMakeLists.txt +++ b/anypiab/CMakeLists.txt @@ -2,6 +2,23 @@ cmake_minimum_required(VERSION 3.10) project(anypiab) +if(CMAKE_SYSTEM_NAME STREQUAL Emscripten) + # CMake's Emscripten settings search for everything under + # the toolchain prefix, this breaks Boost find_package. + # Turn this off just around the Boost find_package. + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + + # On macOS Boost libraries are built as .bc and .dylib, + # but CMake Emscripten's settings for .so and .a by default + if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) + set(CMAKE_FIND_LIBRARY_SUFFIXES .bc .dylib) + endif() + + # Create .html launcher as well + set(CMAKE_EXECUTABLE_SUFFIX ".html") +endif() + add_subdirectory(../oactobjs32/misc ${CMAKE_BINARY_DIR}/misc) add_subdirectory(../oactobjs32/piadata ${CMAKE_BINARY_DIR}/piadata) add_subdirectory(../oactobjs32/piaout ${CMAKE_BINARY_DIR}/piaout) @@ -15,10 +32,15 @@ set(SOURCES find_package(Boost 1.64.0 REQUIRED COMPONENTS date_time) +if(CMAKE_SYSTEM_NAME STREQUAL Emscripten) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + add_executable(${PROJECT_NAME} ${SOURCES}) if(NOT DEFINED ANYPIATEST) - add_compile_definitions("ANYPIAB") + add_compile_definitions("ANYPIAB" "DETAILS") endif(NOT DEFINED ANYPIATEST) # On Linux, the order of these libraries matters! diff --git a/anypiab/anypiab.vcxproj b/anypiab/anypiab.vcxproj index 6931b16..276cf9f 100644 --- a/anypiab/anypiab.vcxproj +++ b/anypiab/anypiab.vcxproj @@ -118,7 +118,7 @@ Disabled ..\oactobjs32;..\oactobjs32\include;..\oactobjs32\windows;..\oactobjs32\boost_1_64_0;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;ANYPIAB;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CONSOLE;ANYPIAB;DETAILS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug