test.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
  2. # PGI compiler doesn't add build id to binaries by default
  3. if(CMAKE_CXX_COMPILER_ID STREQUAL "PGI")
  4. string(APPEND CMAKE_EXE_LINKER_FLAGS "-Wl,--build-id")
  5. string(APPEND CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id")
  6. endif()
  7. set(CMAKE_BUILD_TYPE Debug)
  8. # for rpm packages execute flag must be set for shared libs if debuginfo
  9. # packages are generated
  10. set(CPACK_RPM_INSTALL_WITH_EXEC TRUE)
  11. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
  12. "int test_lib();\n")
  13. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
  14. "#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
  15. add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
  16. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
  17. "#include \"test_lib.hpp\"\nint main() {return test_lib();}\n")
  18. add_executable(test_prog "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
  19. target_link_libraries(test_prog test_lib)
  20. install(TARGETS test_prog DESTINATION foo COMPONENT applications)
  21. install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers)
  22. install(TARGETS test_lib DESTINATION bas COMPONENT libs)
  23. set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT")
  24. set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON)
  25. # test that components with debuginfo enabled still honor
  26. # CPACK_PACKAGE_FILE_NAME setting
  27. set(CPACK_RPM_PACKAGE_NAME "Debuginfo")
  28. set(CPACK_PACKAGE_FILE_NAME "TestDinfo-pkg")
  29. set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON)
  30. # test debuginfo package rename
  31. set(CPACK_RPM_DEBUGINFO_FILE_NAME
  32. "@cpack_component@-DebugInfoPackage.rpm")
  33. set(CPACK_RPM_APPLICATIONS_DEBUGINFO_FILE_NAME "RPM-DEFAULT")
  34. set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/src")