90e7fa1ca63d94ab66c9331a750ec57d5cd04061
[roojspacker] / bin / CMakeLists.txt
1 #
2 #
3 # Main target
4 set(ROOJSPACKER_MAIN_VALA_SOURCES
5    main.vala)
6    
7    
8 set(ROOJS_VALA_CUSTOM_VAPIS
9   ${CMAKE_BINARY_DIR}/${LIBRARY_PATH}/${ROOJSPACKER_PKG_NAME}.vapi)
10
11 set(ROOJSPACKER_VALA_PACKAGES
12     glib-2.0  
13     gobject-2.0  
14     gee-0.8 
15     posix 
16     gio-2.0
17     json-glib-1.0
18 )
19
20
21 # Compile Vala sources to C
22 vala_precompile_target(
23   "${PROJECT_NAME}-valabin"
24   ROOJSPACKER_MAIN_C_SOURCES
25   ${ROOJS_VALA_CUSTOM_VAPIS}
26   ${ROOJSPACKER_MAIN_VALA_SOURCES}
27   PACKAGES ${ROOJSPACKER_VALA_PACKAGES}
28   DEPENDS "${ROOJSPACKER_LIBRARY_NAME}-vala")
29
30 # Tell CMake to create an executable named "my-project"
31 add_executable(${PROJECT_NAME}
32         ${ROOJSPACKER_MAIN_C_SOURCES})
33
34 # Make sure the Vala sources are compiled to C before attempting to
35 # build the executable.
36 add_dependencies("${PROJECT_NAME}" "${PROJECT_NAME}-valabin")
37
38 # We need to add the directory where the C header for our library is
39 # installed, otherwise we'll get an error from the C compiler.
40 set_target_properties(${PROJECT_NAME} PROPERTIES
41         INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/roojspacker)
42
43 # Any libraries that your tests need to link to should go here.
44 # Usually this will just be your library.
45 target_link_libraries(${PROJECT_NAME}
46     ${ROOJSPACKER_LIBRARY_NAME})
47
48 # Install the executable.
49 install (TARGETS ${PROJECT_NAME}
50     RUNTIME DESTINATION bin ${CMAKE_INSTALL_BINDIR})
51
52 # Generate a .gitignore
53 file(WRITE  ".gitignore" "# Automatically generated by CMake, do not modify.\n")
54 foreach(file
55     ".gitignore"
56     "roojspacker${CMAKE_EXECUTABLE_SUFFIX}")
57   file(APPEND ".gitignore" "/${file}\n")
58 endforeach(file)
59 foreach(file ${ROOJSPACKER_MAIN_SOURCES})
60   string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" file ${file})
61   file(APPEND ".gitignore" "/${file}\n")
62 endforeach(file)