├── .gitignore ├── libOne.h ├── libTwo.cpp ├── libThree.h ├── libOne.cpp ├── libThree.cpp ├── libTwo.h ├── main.cpp ├── README.md ├── LICENSE └── CMakeLists.txt /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | _debug/ 3 | *.user 4 | -------------------------------------------------------------------------------- /libOne.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ivan Onyshchenko 2 | 3 | #ifndef BUAPP_LIB_ONE_H 4 | #define BUAPP_LIB_ONE_H 5 | 6 | #include 7 | 8 | void printFromLibOne(const std::string& message); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libTwo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ivan Onyshchenko 2 | 3 | #ifndef BUAPP_LIB_TWO_H 4 | #define BUAPP_LIB_TWO_H 5 | 6 | #include 7 | 8 | void printFromLibTwo(const std::string& message); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libThree.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ivan Onyshchenko 2 | 3 | #ifndef BUAPP_LIB_THREE_H 4 | #define BUAPP_LIB_THREE_H 5 | 6 | #include 7 | 8 | void printFromLibThree(const std::string& message); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libOne.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ivan Onyshchenko 2 | 3 | #include 4 | #include 5 | 6 | void printFromLibOne(const std::string& message) 7 | { 8 | std::cout << "From libOne: " << message << std::endl; 9 | } 10 | -------------------------------------------------------------------------------- /libThree.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ivan Onyshchenko 2 | 3 | #include 4 | #include 5 | 6 | void printFromLibThree(const std::string& message) 7 | { 8 | std::cout << "From libThree: " << message << std::endl; 9 | } 10 | -------------------------------------------------------------------------------- /libTwo.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ivan Onyshchenko 2 | 3 | #include 4 | #include 5 | #include "libThree.h" 6 | 7 | void printFromLibTwo(const std::string& message) 8 | { 9 | std::cout << "Entering printFromLibTwo()" << std::endl; 10 | printFromLibThree(message); 11 | std::cout << "Exiting printFromLibTwo()" << std::endl; 12 | } 13 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 Ivan Onyshchenko 2 | 3 | #include "libOne.h" 4 | #include "libTwo.h" 5 | #include 6 | 7 | // main() uses LibOne and LibTwo, LibTwo internally uses LibThree 8 | int main() 9 | { 10 | std::cout << "Entering main()" << std::endl; 11 | printFromLibOne("foo"); 12 | printFromLibTwo("bar"); 13 | std::cout << "Exiting main()" << std::endl; 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | Portable sample app using CMake and CPack. 4 | 5 | The app uses two dynamic libraries, one of them using yet another library: 6 | 7 | ``` 8 | PortableApp 9 | libLibOne.dylib 10 | libLibTwo.dylib 11 | libLibThree.dylib 12 | ``` 13 | 14 | Tags: CMake, CPack, MacOS X bundle, .dmg, portable app. 15 | 16 | # Building 17 | 18 | ``` 19 | mkdir build 20 | cd build 21 | cmake .. 22 | cpack -G DragNDrop 23 | ``` 24 | 25 | # Contacts 26 | You are welcome to contact me at **ivan.onyshchenko (at) gmail.com** in case you have any questions, comments, suggestions or need help building, designing or implementing your product. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Ivan Onyshchenko 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 Ivan Onyshchenko 2 | project(PortableApp LANGUAGES CXX) 3 | cmake_minimum_required(VERSION 3.1) 4 | 5 | # list both source and header files, so they are listed in 6 | # project structure in QtCreator 7 | add_library(LibOne SHARED libOne.cpp libOne.h) 8 | add_library(LibTwo SHARED libTwo.cpp libTwo.h) 9 | add_library(LibThree SHARED libThree.cpp libThree.h) 10 | target_link_libraries(LibTwo LibThree) 11 | 12 | set(APP_NAME PortableApp) 13 | 14 | add_executable(${APP_NAME} MACOSX_BUNDLE main.cpp) 15 | target_link_libraries(${APP_NAME} LibOne LibTwo) 16 | 17 | add_custom_target(Docs SOURCES README.md .gitignore LICENSE) 18 | 19 | # Destination paths below are relative to ${CMAKE_INSTALL_PREFIX} 20 | install(TARGETS ${APP_NAME} 21 | BUNDLE DESTINATION . COMPONENT Runtime 22 | RUNTIME DESTINATION bin COMPONENT Runtime 23 | ) 24 | 25 | # Note Mac specific extension .app 26 | set(APPS "\${CMAKE_INSTALL_PREFIX}/${APP_NAME}.app") 27 | 28 | # Directories to look for dependencies 29 | set(DIRS ${CMAKE_BINARY_DIR}) 30 | 31 | install(CODE "include(BundleUtilities) 32 | fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")") 33 | 34 | set(CPACK_GENERATOR "DRAGNDROP") 35 | include(CPack) 36 | --------------------------------------------------------------------------------