Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Setup CMake to build for macOS
authorSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 3 Oct 2020 09:34:15 +0000 (10:34 +0100)
committerSteve Brokenshire <sbrokenshire@xestia.co.uk>
Sat, 3 Oct 2020 09:34:15 +0000 (10:34 +0100)
16 files changed:
source/CMakeFunctions/Application.cmake
source/CMakeFunctions/CopyLibraries.cmake [new file with mode: 0644]
source/CMakeFunctions/MacOSSupport.cmake [new file with mode: 0644]
source/CMakeFunctions/Options.cmake
source/CMakeFunctions/Packages.cmake
source/CMakeLists.txt
source/actmgr/CMakeLists.txt
source/convert.cpp
source/frmMain.h
source/frmMain.mm
source/main.cpp
source/os/osx/Info.plist [moved from projects/osx/ODTHelpBrowser/Info.plist with 55% similarity]
source/os/osx/XestiaAddressBook.icns [new file with mode: 0644]
source/tools/CMakeLists.txt
source/tools/bitmapcode.cpp
source/tools/generateicnsfile.sh [new file with mode: 0755]

index 87a6208..d3b44f7 100644 (file)
@@ -34,29 +34,13 @@ set(FILE_LIST main.cpp
               frmUpdate.cpp
               frmUpdate.h)
 
-if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+if(APPLE)
     list(APPEND FILE_LIST frmEditAccount.mm
-                             frmNewAccount.mm)
+                          frmNewAccount.mm
+                          frmMain.mm
+                          os/osx/XestiaAddressBook.icns)
 endif()
 
-if (MSVC)
-    list(APPEND FILE_LIST os/msw/xestiaab.rc)
-    add_executable(xestiaab WIN32
-        ${FILE_LIST})
-else()
-    add_executable(xestiaab
-        ${FILE_LIST})
-endif()
-
-
-message("${RUNTIME_OUTPUT_NAME_bitmapcode}")
-
-target_include_directories(xestiaab
-    PUBLIC
-    ".")
-    
-add_dependencies(xestiaab bitmapcode)
-    
 list(APPEND LIBRARIES ${wxWidgets_LIBRARIES}
                       ${LIBXML2_LIBRARY}
                       sfml-audio
@@ -80,10 +64,68 @@ if (MSVC)
                           crypt32)
 endif()
 
-target_link_libraries(xestiaab
-    LINK_PUBLIC
-    ${LIBRARIES}
-)
+if (MSVC)
+    list(APPEND FILE_LIST os/msw/xestiaab.rc)
+    add_executable(xestiaab WIN32
+        ${FILE_LIST})
+elseif(APPLE)
+    # Main icons
+    set_source_files_properties(os/osx/XestiaAddressBook.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
+    set(MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/os/osx/Info.plist")
+    set(CMAKE_BUILD_PATH_USE_ORIGIN TRUE)
+    set(APPS "\${CMAKE_INSTALL_PREFIX}/xestiaab.app")
+    set(DIR ${CMAKE_BINARY_DIR})
+    
+    install(CODE "include(BundleUtilities)
+        fixup_bundle(\"${APPS}\" \"\" \"\")")
+
+    # Documentation
+    file(GLOB DocumentationFiles ${CMAKE_SOURCE_DIR}/../docs/*.fodt)
+    set_source_files_properties(${DocumentationFiles} 
+        PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+
+    add_executable(xestiaab MACOSX_BUNDLE
+        ${FILE_LIST}
+        ${DocumentationFiles}
+        ${FrameworkFiles})
+    
+    install(TARGETS xestiaab
+        BUNDLE DESTINATION . COMPONENT Runtime
+        RUNTIME DESTINATION bin COMPONENT Runtime)
+
+    target_link_libraries(xestiaab LINK_PUBLIC
+                          stdc++
+                          objc
+                          ${COREFOUNDATION_FRAMEWORK}
+                          ${SECURITY_FRAMEWORK}
+                          ${SECURITYINTERFACE_FRAMEWORK}
+                          ${LIBRARIES})
+
+    set_target_properties(xestiaab PROPERTIES
+                          MACOSX_BUNDLE TRUE
+                          MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/os/osx/Info.plist)
+        
+    add_custom_command(
+        TARGET xestiaab
+        COMMAND ${CMAKE_COMMAND} -D SRC=$<TARGET_BUNDLE_DIR:xestiaab>/Contents/MacOS/xestiaab
+                                 -D DST=$<TARGET_BUNDLE_DIR:xestiaab>/Contents/Frameworks
+                                 -D SFML_FRAMEWORKS_LOCATION=${SFML_FRAMEWORKS_LOCATION}
+                                 -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeFunctions/CopyLibraries.cmake
+        POST_BUILD
+    )
+else()
+    add_executable(xestiaab
+        ${FILE_LIST})
+endif()
+
+
+message("${RUNTIME_OUTPUT_NAME_bitmapcode}")
+
+target_include_directories(xestiaab
+    PUBLIC
+    ".")
+    
+add_dependencies(xestiaab bitmapcode)
 
 file(GLOB DOCUMENTATION_INSTALL_FILES "${CMAKE_SOURCE_DIR}/../docs/*")
 foreach(ITEM ${DOCUMENTATION_INSTALL_FILES})
@@ -93,9 +135,3 @@ foreach(ITEM ${DOCUMENTATION_INSTALL_FILES})
         list(APPEND DOCUMENTATION_DEPLOY_DIRECTORIES "${ITEM}")
     endif()
 endforeach()
-
-install(TARGETS xestiaab RUNTIME DESTINATION bin)
-install(TARGETS odthelpbrowser RUNTIME DESTINATION bin)
-install(FILES ${CMAKE_SOURCE_DIR}/xestiaab.1 DESTINATION share/man/man1)
-install(FILES ${DOCUMENTATION_DEPLOY_FILES} DESTINATION share/doc/xestiaab)
-install(FILES ${DOCUMENTATION_DEPLOY_DIRECTORIES} DESTINATION share/doc/xestiaab)
\ No newline at end of file
diff --git a/source/CMakeFunctions/CopyLibraries.cmake b/source/CMakeFunctions/CopyLibraries.cmake
new file mode 100644 (file)
index 0000000..d5371ef
--- /dev/null
@@ -0,0 +1,230 @@
+# list command no longer ignores empty elements
+cmake_policy(SET CMP0007 NEW)
+
+function(Execute)
+    list(POP_FRONT ARGV outlist)
+
+    execute_process(
+        COMMAND ${ARGV}
+        OUTPUT_VARIABLE cmd_out
+        OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+
+    string(REPLACE "\n" ";" cmd_out "${cmd_out}")
+    list(TRANSFORM cmd_out STRIP)
+    set(${outlist} ${cmd_out} PARENT_SCOPE)
+endfunction()
+
+function(GatherRuntimePaths source)
+    Execute(output otool -l ${source})
+
+    set (line_index 0)
+    foreach (line ${output})
+        if(line MATCHES "^.*cmd LC_RPATH")
+            set(line_index 1)
+            continue()
+        endif()
+
+        if (line_index EQUAL 1)
+            set(line_index 2)
+            continue()
+        endif()
+
+        if (line_index EQUAL 2)
+            string(REGEX REPLACE "^.*path" "" extracted_path ${line})
+            string(REGEX REPLACE "\\(offset .*\\)$" "" extracted_path ${extracted_path})
+            string(STRIP ${extracted_path} extracted_path)
+            list(APPEND runpaths ${extracted_path})
+            set(line_index 0)
+            continue()
+        endif()
+    endforeach()
+
+    set(runpaths ${runpaths} PARENT_SCOPE)
+endfunction()
+
+function(GatherSFMLLibrariesForCopying libraries postcmds)
+   foreach(library ${libraries})
+       Execute(output otool -L ${library})
+
+       foreach(line ${output})
+           if(line MATCHES "^.*libsfml.*.[^0-9].[^0-9].[^0-9].*\\.dylib ")
+                string(REGEX REPLACE "dylib .*" "dylib" line "${line}")
+
+                if(line MATCHES "^@rpath/")
+                    get_filename_component(refname "${line}" NAME)
+                    list(APPEND postcmds "sh -c 'install_name_tool -change ${line} @executable_path/../Frameworks/${refname} ${library}'")
+                    list(APPEND libs ${dylib_location})
+                endif()
+           elseif(line MATCHES "^@rpath/../Frameworks/.*.framework/Versions/.*/.*")
+                string(REGEX MATCH "^@rpath/../Frameworks/(.*)/Versions/.*$" _ ${line})
+                list(APPEND frameworksToCopy ${CMAKE_MATCH_1})
+           endif()
+       endforeach()
+   endforeach()
+
+    set(postcmds ${postcmds} PARENT_SCOPE)
+    set(frameworksToCopy ${frameworksToCopy} PARENT_SCOPE)
+endfunction()
+
+function (InstallSFMLDependencies frameworks postcmds destination)
+    foreach (framework ${frameworks})
+        unset(frameworkLocation)
+        string(REGEX MATCH "(.*).framework" _ ${framework})
+        string(APPEND frameworkLocation ${SFML_FRAMEWORKS_LOCATION} "/" ${framework})
+        file(INSTALL ${frameworkLocation} DESTINATION ${destination})
+    endforeach()
+endfunction()
+
+function(AdjustSFMLDependencies libraries destination)
+    foreach (libraryFilename ${libraries})
+        string(REGEX MATCH "(.*).framework" _ ${libraryFilename})
+        string(CONCAT libraryName ${CMAKE_MATCH_1})
+        string(CONCAT frameworkLocation ${destination} "/" ${libraryFilename} "/" ${libraryName})
+        Execute(output otool -L ${frameworkLocation})
+
+       foreach (oldLocation ${output})
+            string(REGEX REPLACE " \\\(compatibility .*" "" oldLocation ${oldLocation})
+            if(oldLocation MATCHES "^@rpath")
+                string(REPLACE "@rpath/" "@executable_path/" newLocation ${oldLocation})
+                execute_process(
+                   COMMAND sh -c "install_name_tool -change ${oldLocation} ${newLocation} ${frameworkLocation}"
+                   COMMAND_ECHO STDOUT
+                )
+            endif()
+        endforeach()
+    endforeach()
+endfunction()
+
+function(AdjustSFMLLibraries libraries)
+    foreach(library ${libraries})
+        Execute(output otool -L ${library})
+
+        foreach(oldLocation ${output})
+            string(REGEX REPLACE " \\\(compatibility .*" "" oldLocation ${oldLocation})
+            if(oldLocation MATCHES "^@rpath")
+                string(REPLACE "@rpath/" "@executable_path/" newLocation ${oldLocation})
+                execute_process(
+                   COMMAND sh -c "install_name_tool -change ${oldLocation} ${newLocation} ${library}"
+                   COMMAND_ECHO STDOUT
+                )
+            endif()
+        endforeach()
+    endforeach()
+endfunction()
+
+function(GatherLibrariesForCopying source)
+    if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
+        # Gather runtime paths first.
+        if(NOT source MATCHES "^@rpath")
+            GatherRuntimePaths(${source})
+        endif()
+
+        Execute(output otool -L ${source})
+
+        get_filename_component(LibraryName "${source}" NAME)
+    
+        if(LibraryName MATCHES ".*dylib")
+            string(PREPEND LibraryName "${DST}/")
+        else()
+            set(LibraryName "${source}")
+        endif()
+
+        foreach (line ${output})
+            if(line MATCHES "^@rpath/../Frameworks/.*.framework/Versions/.*/.*")
+                continue()
+            endif()
+
+            if(line MATCHES "^@rpath")
+                string(REGEX REPLACE "^@rpath/" "" filename ${line})
+                string(REGEX REPLACE "dylib .*" "dylib" filename ${filename})
+
+                set(dylib_found 0)                
+                foreach (runpath ${runpaths})
+                    string(CONCAT dylib_location ${runpath} "/" ${filename})
+                    if (EXISTS ${dylib_location})
+                        set(dylib_location ${dylib_location} PARENT_SCOPE)
+                        set(dylib_found 1)
+                        break()
+                    endif()
+                endforeach()
+
+                if(dylib_found EQUAL 0)
+                    message(FATAL_ERROR "Unable to find dynamic library ${filename} within the runtime paths.")
+                endif()
+            endif()
+
+            # Dynamic Libraries
+            if(line MATCHES "^.*libwx.*\\.dylib " )
+                string(REGEX REPLACE "dylib .*" "dylib" line "${line}")
+                if(NOT line STREQUAL "${source}" AND NOT line MATCHES "@executable")
+                    set(lib ${line})
+                    if(line MATCHES "^@rpath/")
+                        list(APPEND libs ${dylib_location})
+                    else()
+                        list(APPEND libs ${lib})
+                    endif()
+                    get_filename_component(refname "${lib}" NAME)
+                    list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'")
+                    
+                    GatherLibrariesForCopying(${lib})
+                endif()
+            elseif(line MATCHES "^.*libsfml.*.[^0-9].[^0-9].[^0-9].*\\.dylib ")
+                string(REGEX REPLACE "dylib .*" "dylib" line "${line}")
+                set(lib ${line})
+                if(line MATCHES "^@rpath/")
+                    get_filename_component(refname "${dylib_location}" NAME)
+                    list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'")
+                    list(APPEND libs ${dylib_location})
+                elseif(line MATCHES "^@executable_path/")
+                    continue()
+                else()
+                    get_filename_component(refname "${lib}" NAME)
+                    list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'")
+                    list(APPEND libs ${lib})
+                endif()
+                get_filename_component(libraryPath "${LibraryName}" DIRECTORY)
+                string(APPEND libraryPath "/../Frameworks/${refname}")
+                list(APPEND sfmllibs ${libraryPath})
+            elseif(line MATCHES "^.*libcurl.[0-9]\\.dylib " OR
+                   line MATCHES "^.*libxml2.[0-9]\\.dylib ")
+                string(REGEX REPLACE "dylib .*" "dylib" line "${line}")
+                set(lib ${line})
+
+                if(line MATCHES "^@rpath/")
+                    get_filename_component(refname "${dylib_location}" NAME)
+                    list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'")
+                    list(APPEND libs ${dylib_location})
+                elseif(line MATCHES "^@executable_path/")
+                    continue()
+                else()
+                    get_filename_component(refname "${lib}" NAME)
+                    list(APPEND postcmds "sh -c 'install_name_tool -change ${lib} @executable_path/../Frameworks/${refname} ${LibraryName}'")
+                    list(APPEND libs ${lib})
+                endif()
+            endif()
+        endforeach()
+    endif()
+
+    set(libs ${libs} PARENT_SCOPE)
+    set(sfmllibs ${sfmllibs} PARENT_SCOPE)
+    set(postcmds ${postcmds} PARENT_SCOPE)
+endfunction()
+
+GatherLibrariesForCopying(${SRC})
+
+list(REMOVE_DUPLICATES libs)
+file(INSTALL ${libs} DESTINATION ${DST} FOLLOW_SYMLINK_CHAIN)
+
+GatherSFMLLibrariesForCopying("${sfmllibs}" "${postcmds}")
+InstallSFMLDependencies("${frameworksToCopy}" "${postcmds}" "${DST}")
+
+foreach(cmd ${postcmds})
+    execute_process(
+        COMMAND sh -c "${cmd}"
+        COMMAND_ECHO STDOUT
+    )
+endforeach()
+
+AdjustSFMLLibraries("${sfmllibs}")
+AdjustSFMLDependencies("${frameworksToCopy}" ${DST})
diff --git a/source/CMakeFunctions/MacOSSupport.cmake b/source/CMakeFunctions/MacOSSupport.cmake
new file mode 100644 (file)
index 0000000..0414679
--- /dev/null
@@ -0,0 +1,6 @@
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -std=c++11")
+#add_definitions(-std=c++11)
+
+find_library(COREFOUNDATION_FRAMEWORK CoreFoundation)
+find_library(SECURITY_FRAMEWORK Security)
+find_library(SECURITYINTERFACE_FRAMEWORK SecurityInterface)
index 5801a3b..017958a 100644 (file)
@@ -1,3 +1,11 @@
 include(CMakeDependentOption)
 
 option(XestiaAddressBook_UNIT_TESTING  "Enable unit testing"  OFF)
+
+if(APPLE)
+    set(SFML_FRAMEWORKS_LOCATION "" CACHE PATH "Location for the SFML framework dependencies.")
+
+    if(NOT EXISTS ${SFML_FRAMEWORKS_LOCATION})
+        message(FATAL_ERROR "The location given by SFML_FRAMEWORKS_LOCATION does not exist.")
+    endif()
+endif()
index 4678364..c42d5b5 100644 (file)
@@ -7,12 +7,24 @@ include(${wxWidgets_USE_FILE})
 
 find_package(LibXml2 REQUIRED)
 include_directories(${LIBXML2_INCLUDE_DIRS})
+if (APPLE)
+    if (LIBXML2_LIBRARY MATCHES "^/usr/lib/.*")
+        message(FATAL_ERROR "Use of macOS's internal libxml2 dynamic library is not allowed.")
+    endif()
+endif()
 
-find_package(Iconv REQUIRED)
-include_directories(${Iconv_INCLUDE_DIR})
+if(!APPLE)
+    find_package(Iconv REQUIRED)
+    include_directories(${Iconv_INCLUDE_DIR})
+endif()
 
 find_package(CURL REQUIRED)
 include_directories(${CURL_INCLUDE_DIRS})
+if (APPLE)
+    if (LIBXML2_LIBRARY MATCHES "^/usr/lib/.*")
+        message(FATAL_ERROR "Use of macOS's internal libcurl dynamic library is not allowed.")
+    endif()
+endif()
 
 find_package(SFML COMPONENTS audio REQUIRED)
 include_directories(${SFML_DIR}/../include)
index 097c584..814b433 100644 (file)
@@ -7,6 +7,10 @@ set(CMAKE_CXX_STANDARD 11)
 include(Options)
 include(Packages)
 
+if (APPLE)
+    include(MacOSSupport)
+endif()
+
 if (XestiaAddressBook_UNIT_TESTING)
     enable_testing()
     find_package(GTest REQUIRED)
index 0f69875..9e87ae0 100644 (file)
@@ -4,8 +4,8 @@ set(FILE_LIST frmActivityMgr.cpp
               frmActivityMgr.h
               frmActivityMgr-tasks.cpp)
 
-if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
-    list(APPEND ${FILE_LIST} frmActivityMgr.mm)
+if(APPLE)
+    list(APPEND FILE_LIST frmActivityMgr.mm)
 endif()
 
 add_library(${TARGET_NAME}
index 89227cb..d734519 100644 (file)
@@ -193,10 +193,10 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat,
                // Write out the data to the console.
                
                FinalData.Trim();
-               std::cout << FinalData << std::endl;
+               std::cout << FinalData.ToStdString() << std::endl;
        
        }
        
        return CONVERTRESULT_OK;
        
-}
\ No newline at end of file
+}
index dcc18bb..4a2313c 100644 (file)
@@ -125,7 +125,7 @@ class frmMain : public frmMainADT
                std::map<int, wxString> AccountAccDirList;
 #if defined(__APPLE__)
                std::map<int, SecTrustRef> AccountTrustData;
-               NSRunningApplication *helpBrowserProcess;
+               NSRunningApplication *helpBrowserProcess = nil;
 #elif defined(__WIN32__)
                std::map<int, PCCERT_CONTEXT> AccountCertificateData;
 #else
index 7e6b563..39200a7 100644 (file)
@@ -83,7 +83,7 @@ void frmMain::DisplayHelpBrowser()
                helpBrowserDocumentationPath = [[NSBundle mainBundle] pathForResource:@"Documentation (en_GB)" ofType:@"fodt"];
        }
        
-       NSURL *helpBrowserExecutableURL = [[NSBundle mainBundle] URLForResource:@"ODTHelpBrowser" withExtension:@"app"];
+       NSURL *helpBrowserExecutableURL = [[NSBundle mainBundle] URLForResource:@"odthelpbrowser" withExtension:@"app"];
 
        NSArray *args = [NSArray arrayWithObjects:@"-d", helpBrowserDocumentationPath, nil];
        NSDictionary *helpBrowserArguments = [NSDictionary dictionaryWithObject:args
index 3de7a64..2140dfd 100644 (file)
@@ -63,7 +63,7 @@ bool XestiaABApp::OnInit()
        // Setup the locale.
 
        wxLocale locale;
-       locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT);
+    locale.Init(wxLANGUAGE_DEFAULT, wxLOCALE_LOAD_DEFAULT);
 
        static const wxCmdLineEntryDesc g_cmdLineDesc [] =
        {
@@ -367,4 +367,4 @@ bool XestiaABApp::OnInit()
    
        return true;
 
-}
\ No newline at end of file
+}
similarity index 55%
rename from projects/osx/ODTHelpBrowser/Info.plist
rename to source/os/osx/Info.plist
index 17ba4a4..dc5cfd0 100644 (file)
@@ -3,32 +3,32 @@
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
-       <string>$(DEVELOPMENT_LANGUAGE)</string>
+       <string>English</string>
        <key>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
-       <key>CFBundleIconFile</key>
+       <key>CFBundleGetInfoString</key>
        <string></string>
+       <key>CFBundleIconFile</key>
+       <string>XestiaAddressBook</string>
        <key>CFBundleIdentifier</key>
-       <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+       <string>uk.co.xestia.addressbook</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleLongVersionString</key>
-       <string>$(PRODUCT_VERSION) (c) 2013 - 2018 Xestia Software Development</string>
+       <string></string>
        <key>CFBundleName</key>
-       <string>$(PRODUCT_NAME)</string>
+       <string></string>
        <key>CFBundlePackageType</key>
-       <string>XSD</string>
+       <string>APPL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.0.0</string>
+       <string></string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
        <key>CFBundleVersion</key>
-       <string>1.0.0</string>
-       <key>LSApplicationCategoryType</key>
-       <string>public.app-category.productivity</string>
-       <key>LSMinimumSystemVersion</key>
-       <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
+       <string>0.24</string>
+       <key>CSResourcesFileMapped</key>
+       <true/>
        <key>NSHumanReadableCopyright</key>
-       <string>Copyright © 2018 Xestia Software Development. All rights reserved.</string>
-       <key>NSPrincipalClass</key>
-       <string>wxNSApplication</string>
+       <string>(c) 2012-2020 Xestia Software Development</string>
 </dict>
 </plist>
diff --git a/source/os/osx/XestiaAddressBook.icns b/source/os/osx/XestiaAddressBook.icns
new file mode 100644 (file)
index 0000000..4ff0067
Binary files /dev/null and b/source/os/osx/XestiaAddressBook.icns differ
index a34ec67..8f1e901 100644 (file)
@@ -1,6 +1,6 @@
 add_executable(bitmapcode
     bitmapcode.cpp)
-    
+
 if (MSVC)
 add_custom_command(
     TARGET bitmapcode
@@ -10,6 +10,7 @@ endif()
     
 target_link_libraries(bitmapcode
     LINK_PUBLIC
+    c++
     ${wxWidgets_LIBRARIES})
 
 set (sources 
@@ -26,6 +27,8 @@ set (sources
 
 if (WIN32)
     add_executable(odthelpbrowser WIN32 ${sources})
+elseif (APPLE)
+    add_executable(odthelpbrowser MACOSX_BUNDLE ${sources})
 else()
     add_executable(odthelpbrowser ${sources})
 endif()
index b054104..4425062 100644 (file)
@@ -100,8 +100,8 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter)
        // Setup the inclusion guard.
     
        cppfile << "#include <iostream>" << endl << endl;    
-       cppfile << "#ifndef " << outname.c_str() << "_CPP" << endl;
-       cppfile << "#define " << outname.c_str() << "_CPP" << endl << endl;
+       cppfile << "#ifndef " << outname.ToStdString() << "_CPP" << endl;
+       cppfile << "#define " << outname.ToStdString() << "_CPP" << endl << endl;
     
        outname.Clear();
        outname.Append(wxString::FromUTF8(DirFilenameOnly.c_str()));
@@ -113,7 +113,7 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter)
     
        // Convert the PNG file into an unsigned char array.
     
-       cppfile << "static unsigned char " << outname.c_str() <<
+       cppfile << "static unsigned char " << outname.ToStdString() <<
                "[] = {" << endl;
     
        while (pngfile){
@@ -148,10 +148,9 @@ void CreateCPPFile(wxString dirfilename, wxString PNGFilename, int* counter)
        cppfile << "#endif" << endl << endl;
        cppfile.close();
     
-       cout << "CPP\t" << CPPFilename.c_str() << endl;    
+       cout << "CPP\t" << CPPFilename.ToStdString() << endl;
     
        ++*counter;
-    
 }
 
 void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist, 
@@ -171,7 +170,7 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist,
     
        bool fmatch = FALSE;
        wxString finaldirname;
-       wxString HPPFilename = dirfilename.c_str();
+       wxString HPPFilename = dirfilename.ToStdString();
 
        wxString DirFilenameOnly;
        wxString HPPFilenameOnly;
@@ -224,8 +223,8 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist,
 #endif
 
        hppfile << "#include <iostream>" << endl << endl;
-       hppfile << "#ifndef " << finaldirname.c_str() << "_H" << endl;
-       hppfile << "#define " << finaldirname.c_str() << "_H" << endl << endl;
+       hppfile << "#ifndef " << finaldirname.ToStdString() << "_H" << endl;
+       hppfile << "#define " << finaldirname.ToStdString() << "_H" << endl << endl;
        hppfile << "// List all CPP files in the directory." << endl << endl;
     
        // Write each CPP file into the header file.
@@ -255,8 +254,8 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist,
                CPPFileOnly.RemoveLast(4);
                CPPFileOnly.Append(wxT(".cpp"));
 
-               hppfile << "#include \"" << DirFilenameOnly.c_str() <<
-                       "/" << CPPFileOnly.c_str() << "\"" << endl;
+               hppfile << "#include \"" << DirFilenameOnly.ToStdString() <<
+                       "/" << CPPFileOnly.ToStdString() << "\"" << endl;
 
        }
     
@@ -267,7 +266,7 @@ void CreateHPPFileDir(wxString dirfilename, wxArrayString filelist,
     
        // Increment the HPP file counter.
 
-       cout << "HPPDIR\t" << HPPFilename.c_str() << endl;
+       cout << "HPPDIR\t" << HPPFilename.ToStdString() << endl;
        ++*counter;
     
 }
@@ -386,7 +385,7 @@ int main(int argc, char *argv[])
     
        DirFilenameWxS.Empty();
 
-       std::cout << BitmapHeaderFilename.c_str() << std::endl;
+       std::cout << BitmapHeaderFilename.ToStdString() << std::endl;
 
 #if defined(__WIN32__)
 
@@ -448,7 +447,7 @@ int main(int argc, char *argv[])
                for (int fi = 0; fi < filelist.GetCount(); fi++)
                {
                
-                       CreateCPPFile(dirlist[bi].wc_str(), filelist[fi].wc_str(), &cppg);
+                       CreateCPPFile(dirlist[bi].ToStdString(), filelist[fi].ToStdString(), &cppg);
                        fp++;
                        
                }
@@ -487,12 +486,12 @@ int main(int argc, char *argv[])
 
 #elif defined(__WIN32__)
 
-               finalhppfile << "#include \"bitmaps\\" << DirNameSplit.c_str() <<
+               finalhppfile << "#include \"bitmaps\\" << DirNameSplit.ToStdString() <<
                        ".h\"" << endl;
 
 #else
 
-               finalhppfile << "#include \"bitmaps/" << DirNameSplit.c_str() <<
+               finalhppfile << "#include \"bitmaps/" << DirNameSplit.ToStdString() <<
                        ".h\"" << endl;
 
 #endif
diff --git a/source/tools/generateicnsfile.sh b/source/tools/generateicnsfile.sh
new file mode 100755 (executable)
index 0000000..50091c5
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+if [ -z $1 ]; then
+  echo "Usage: $0 <pngfile>"
+  exit
+fi
+
+IMAGELOCATION=$1
+IMAGEFILENAME=${IMAGELOCATION##*/}
+IMAGENAME="${IMAGEFILENAME%.*}"
+
+mkdir $IMAGENAME.iconset
+sips $IMAGELOCATION -z 16 16 --out $IMAGENAME.iconset/icon_16x16.png
+sips $IMAGELOCATION -z 32 32 --out $IMAGENAME.iconset/icon_16x16@2x.png
+sips $IMAGELOCATION -z 32 32 --out $IMAGENAME.iconset/icon_32x32.png
+sips $IMAGELOCATION -z 64 64 --out $IMAGENAME.iconset/icon_32x32@2x.png
+sips $IMAGELOCATION -z 128 128 --out $IMAGENAME.iconset/icon_128x128.png
+sips $IMAGELOCATION -z 256 256 --out $IMAGENAME.iconset/icon_128x128@2x.png
+sips $IMAGELOCATION -z 256 256 --out $IMAGENAME.iconset/icon_256x256.png
+sips $IMAGELOCATION -z 512 512 --out $IMAGENAME.iconset/icon_256x256@2x.png
+sips $IMAGELOCATION -z 512 512 --out $IMAGENAME.iconset/icon_512x512.png
+cp $IMAGELOCATION $IMAGENAME.iconset/icon_512x512@2x.png
+iconutil -c icns $IMAGENAME.iconset
+rm $IMAGENAME.iconset/*
+rmdir $IMAGENAME.iconset
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy