Skip to content

Commit

Permalink
Merge pull request #58 from cjcliffe/osx-app-build
Browse files Browse the repository at this point in the history
OSX App Build
  • Loading branch information
cjcliffe committed Feb 22, 2015
2 parents 3ea528f + 009e20e commit adf160c
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 33 deletions.
100 changes: 93 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required (VERSION 2.8)

IF (NOT APPLE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
ENDIF(NOT APPLE)


macro(configure_files srcDir destDir globStr)
message(STATUS "Copying ${srcDir}/${globStr} to directory ${destDir}")
Expand Down Expand Up @@ -63,7 +66,7 @@ SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/${EX_PLATFORM_

find_package(OpenGL REQUIRED)

find_package(wxWidgets REQUIRED gl core base)
find_package(wxWidgets COMPONENTS gl core base REQUIRED)
set(wxWidgets_CONFIGURATION mswu)
include(${wxWidgets_USE_FILE})

Expand Down Expand Up @@ -183,6 +186,7 @@ IF (APPLE)
set(RTLSDR_LIB "/opt/local/lib" CACHE FILEPATH "RTL-SDR Lib Path")
include_directories(${RTLSDR_INCLUDE})
link_directories(${RTLSDR_LIB})
set(LIB_DIRS "${LIB_DIRS} ${RTLSDR_LIB}")

set(FFTW_LIB fftw3f)
set(LIQUID_LIB liquid)
Expand All @@ -193,6 +197,8 @@ IF (APPLE)

FIND_LIBRARY(COREAUDIO_LIBRARY CoreAudio)
SET (OTHER_LIBRARIES ${COREAUDIO_LIBRARY})
set(BUNDLE_APP OFF CACHE BOOL "Bundle Application")

ENDIF (APPLE)


Expand Down Expand Up @@ -296,17 +302,18 @@ include_directories (

ELSE (MSVC)
ADD_DEFINITIONS(
-std=c++0x # or -std=c++11
-std=c++0x
-pthread
)
ENDIF(MSVC)

configure_files(${PROJECT_SOURCE_DIR}/font ${CMAKE_BINARY_DIR}/${EX_PLATFORM_NAME} "*.fnt")
configure_files(${PROJECT_SOURCE_DIR}/font ${CMAKE_BINARY_DIR}/${EX_PLATFORM_NAME} "*.png")

add_executable(CubicSDR ${cubicsdr_sources} ${cubicsdr_headers})

target_link_libraries(CubicSDR rtlsdr ${LIQUID_LIB} ${FFTW_LIB} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${OTHER_LIBRARIES})
IF (NOT BUNDLE_APP)
configure_files(${PROJECT_SOURCE_DIR}/font ${CMAKE_BINARY_DIR}/${EX_PLATFORM_NAME} "*.fnt")
configure_files(${PROJECT_SOURCE_DIR}/font ${CMAKE_BINARY_DIR}/${EX_PLATFORM_NAME} "*.png")
add_executable(CubicSDR ${cubicsdr_sources} ${cubicsdr_headers})
target_link_libraries(CubicSDR rtlsdr ${LIQUID_LIB} ${FFTW_LIB} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${OTHER_LIBRARIES})
ENDIF (NOT BUNDLE_APP)

IF (MSVC)
set_target_properties(CubicSDR PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
Expand All @@ -320,3 +327,82 @@ IF (MSVC)
set(CMAKE_CREATE_WIN32_EXE "/SUBSYSTEM:WINDOWS /ENTRY:\"mainCRTStartup\"")
ENDIF(MSVC)

IF (APPLE AND BUNDLE_APP)
PROJECT(CubicSDR)
SET(MACOSX_BUNDLE_BUNDLE_NAME CubicSDR)

ADD_DEFINITIONS(
-std=c++0x
-pthread
-D_OSX_APP_
-DHAVE_TYPE_TRAITS=1
-mmacosx-version-min=10.9
)

ADD_EXECUTABLE(CubicSDR
MACOSX_BUNDLE
${cubicsdr_sources}
${cubicsdr_headers}
${PROJECT_SOURCE_DIR}/font/vera_sans_mono12.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono16.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono18.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono24.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono32.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono48.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono12_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono16_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono18_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono24_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono32_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono48_0.png
${PROJECT_SOURCE_DIR}/icon/CubicSDR.icns
)

SET_SOURCE_FILES_PROPERTIES(
${PROJECT_SOURCE_DIR}/font/vera_sans_mono12.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono16.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono18.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono24.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono32.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono48.fnt
${PROJECT_SOURCE_DIR}/font/vera_sans_mono12_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono16_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono18_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono24_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono32_0.png
${PROJECT_SOURCE_DIR}/font/vera_sans_mono48_0.png
${PROJECT_SOURCE_DIR}/icon/CubicSDR.icns
PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)

target_link_libraries(CubicSDR rtlsdr ${LIQUID_LIB} ${FFTW_LIB} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${OTHER_LIBRARIES})
SET_TARGET_PROPERTIES(CubicSDR PROPERTIES MACOSX_BUNDLE TRUE)

SET_TARGET_PROPERTIES(CubicSDR PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "CubicSDR"
# MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
# MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}"
# MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.cubicproductions.cubicsdr"
MACOSX_BUNDLE_ICON_FILE CubicSDR.icns
)

SET(APPS "${CMAKE_BINARY_DIR}/${EX_PLATFORM_NAME}/CubicSDR.app")
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

INSTALL(CODE "
SET(BU_COPY_FULL_FRAMEWORK_CONTENTS ON)
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${RTLSDR_LIB}\")
VERIFY_APP(\"${APPS}\")
" COMPONENT Runtime)

INSTALL(TARGETS CubicSDR
BUNDLE DESTINATION . COMPONENT Runtime
)

set(CPACK_BINARY_DRAGNDROP ON)
include(CPack)
ENDIF (APPLE AND BUNDLE_APP)
Binary file added icon/CubicSDR.icns
Binary file not shown.
Binary file added icon/CubicSDR.ico
Binary file not shown.
18 changes: 18 additions & 0 deletions src/CubicSDR.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define OPENGL

#include "CubicSDRDefs.h"

#include "wx/wxprec.h"

#ifndef WX_PRECOMP
Expand All @@ -13,9 +15,25 @@
#include "CubicSDR.h"
#include "AppFrame.h"

#ifdef _OSX_APP_
#include "CoreFoundation/CoreFoundation.h"
#endif

IMPLEMENT_APP(CubicSDR)

bool CubicSDR::OnInit() {
#ifdef _OSX_APP_
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{
// error!
}
CFRelease(resourcesURL);
chdir(path);
#endif

if (!wxApp::OnInit())
return false;

Expand Down
1 change: 1 addition & 0 deletions src/audio/AudioThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <vector>
#include <algorithm>
#include "DemodulatorThread.h"
#include <memory.h>

#ifdef USE_MIXER
std::map<int, AudioThread *> AudioThread::deviceController;
Expand Down
7 changes: 0 additions & 7 deletions src/audio/AudioThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
#include <map>
#include <string>
#include <atomic>
#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/thread.h"

#include "AudioThread.h"
#include "ThreadQueue.h"
Expand Down
7 changes: 6 additions & 1 deletion src/demod/DemodulatorThread.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#include "DemodulatorThread.h"
#include "CubicSDRDefs.h"
#include "DemodulatorThread.h"
#include <vector>

#include <cmath>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

#ifdef __APPLE__
#include <pthread.h>
#endif
Expand Down
7 changes: 0 additions & 7 deletions src/demod/DemodulatorWorkerThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

#include <queue>
#include <vector>
#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/thread.h"

#include "liquid/liquid.h"
#include "AudioThread.h"
Expand Down
7 changes: 0 additions & 7 deletions src/sdr/SDRThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@

#include <atomic>

#include "wx/wxprec.h"
#include "rtl-sdr.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/thread.h"

#include "ThreadQueue.h"
#include "DemodulatorMgr.h"

Expand Down
6 changes: 2 additions & 4 deletions src/visual/PrimaryGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ void PrimaryGLContext::CheckGLError() {
return;

if (err == errLast) {
wxLogError
(wxT("OpenGL error state couldn't be reset."));
std::cout << "OpenGL error state couldn't be reset." << std::endl;
return;
}

errLast = err;

wxLogError
(wxT("OpenGL error %d"), err);
std::cout << "OpenGL Error " << err << std::endl;
}
}

Expand Down

0 comments on commit adf160c

Please sign in to comment.