Fix image links in README.md
[junction.git] / cmake / AddSample.cmake
1 #---------------------------------------------------------------------------
2 # This script is included from the CMakeLists.txt (listfile) of sample applications.
3 #---------------------------------------------------------------------------
4
5 if(NOT DEFINED PROJECT_NAME)
6     message(FATAL_ERROR "project() should be called before including \"${CMAKE_CURRENT_LIST_FILE}\".")
7 endif()
8 if(NOT DEFINED SAMPLE_NAME)
9     message(FATAL_ERROR "SAMPLE_NAME should be set before including \"${CMAKE_CURRENT_LIST_FILE}\".")
10 endif()
11
12 # Were we included from the root listfile?
13 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
14     # Yes, it's the root.
15     include("${CMAKE_CURRENT_LIST_DIR}/JunctionProjectDefs.cmake")
16     ApplyTurfBuildSettings()
17     add_subdirectory(${JUNCTION_ROOT} junction)
18 elseif(NOT JUNCTION_FOUND)
19     # No, it was added from a parent listfile (via add_subdirectory).
20     # The parent is responsible for finding Junction before adding the sample.
21     # (Or, Junction's listfile is the root, in which case Junction is already found.)
22     message(FATAL_ERROR "JUNCTION_FOUND should already be set when \"${CMAKE_CURRENT_SOURCE_FILE}\" is not the root listfile.")
23 endif()
24
25 # Define executable target.
26 set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mycompany.\${PRODUCT_NAME:identifier}")
27 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
28 GetFilesWithSourceGroups(GLOB SAMPLE_FILES ${CMAKE_CURRENT_SOURCE_DIR} *)
29 add_executable(${SAMPLE_NAME} MACOSX_BUNDLE ${SAMPLE_FILES})
30 set_target_properties(${SAMPLE_NAME} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
31 set_target_properties(${SAMPLE_NAME} PROPERTIES FOLDER samples)
32 install(TARGETS ${SAMPLE_NAME} DESTINATION bin)
33
34 # Set include dirs and libraries
35 include_directories(${JUNCTION_ALL_INCLUDE_DIRS})
36 target_link_libraries(${SAMPLE_NAME} ${JUNCTION_ALL_LIBRARIES})
37 AddDLLCopyStep(${SAMPLE_NAME} ${JUNCTION_ALL_DLLS})