NiceModules.cmake 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # get a list of all sub directories in curdir
  2. MACRO(SUBDIRLIST result curdir)
  3. FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
  4. SET(dirlist "")
  5. FOREACH(child ${children})
  6. IF(IS_DIRECTORY ${curdir}/${child})
  7. SET(dirlist ${dirlist} ${child})
  8. ENDIF()
  9. ENDFOREACH()
  10. SET(${result} ${dirlist})
  11. ENDMACRO()
  12. # get absolute path with symlinks resolved
  13. macro(nice_get_real_path VAR PATHSTR)
  14. if(CMAKE_VERSION VERSION_LESS 2.8)
  15. get_filename_component(${VAR} "${PATHSTR}" ABSOLUTE)
  16. else()
  17. get_filename_component(${VAR} "${PATHSTR}" REALPATH)
  18. endif()
  19. endmacro()
  20. macro(nice_build_library)
  21. ADD_LIBRARY("nice_${the_library}" ${NICE_BUILD_LIBS_STATIC_SHARED} ${nice_${the_library}_HDR} ${nice_${the_library}_SRC})
  22. TARGET_LINK_LIBRARIES("nice_${the_library}" ${nice_${the_library}_LINKING_DEPENDENCIES})
  23. #TARGET_LINK_LIBRARIES("nice_${the_library}" ${nice_${the_library}_LINKING_DEPENDENCIES} ${Boost_LIBRARIES} ${OPENGL_LIBRARY} ${GLUT_LIBRARY} ${QT_LIBRARIES})
  24. SET_PROPERTY(TARGET "nice_${the_library}" PROPERTY FOLDER "library")
  25. INSTALL(TARGETS "nice_${the_library}" DESTINATION lib)
  26. configure_file( ../cmake/niceConfig.cmake.in "${PROJECT_BINARY_DIR}/lib/nice_${the_library}Config.cmake" )
  27. endmacro()
  28. #using variables "the_library"
  29. #and subvariables ${nice_${the_library}_PROGFILES_SRC}
  30. macro(nice_add_progs)
  31. if(BUILD_PROGRAMS)
  32. message(STATUS "building progs:")
  33. foreach(__progcpp ${nice_${the_library}_PROGFILES_SRC})
  34. get_filename_component(__progname ${__progcpp} NAME_WE )
  35. message(STATUS "progname: ${__progname} ${__progcpp}")
  36. set(prog_target_name "${the_library}_${__progname}")
  37. ADD_EXECUTABLE( ${prog_target_name} ${__progcpp})
  38. TARGET_LINK_LIBRARIES(${prog_target_name} "nice_${the_library}")
  39. SET_TARGET_PROPERTIES(${prog_target_name} PROPERTIES OUTPUT_NAME "${__progname}")
  40. INSTALL(TARGETS ${prog_target_name} DESTINATION "bin/${the_library}")
  41. SET_PROPERTY(TARGET ${prog_target_name} PROPERTY FOLDER "programs/${the_library}")
  42. endforeach()
  43. endif()
  44. endmacro()
  45. #using variables "the_library"
  46. #and subvariables ${nice_${the_library}_TESTFILES_SRC}
  47. macro(nice_add_unittests)
  48. if(BUILD_UNITTESTS)
  49. INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
  50. message(STATUS "building tests:")
  51. foreach(__testcpp ${nice_${the_library}_TESTFILES_SRC})
  52. get_filename_component(__testname ${__testcpp} NAME_WE )
  53. nice_get_real_path(__testname_abspath ${__testcpp})
  54. get_filename_component(__testname_dir ${__testname_abspath} DIRECTORY)
  55. message(STATUS "unittest: ${__testname} ${__testcpp}")
  56. ADD_EXECUTABLE( ${__testname} ../templates/cppUnitTestRunner.cpp ${__testcpp})
  57. TARGET_LINK_LIBRARIES(${__testname} "nice_${the_library}" ${CPPUNIT_LIBRARIES} )
  58. INSTALL(TARGETS ${__testname} DESTINATION "tests/${the_library}")
  59. SET_PROPERTY(TARGET ${__testname} PROPERTY FOLDER "unittests/${the_library}")
  60. ADD_TEST(${__testname} ${__testname} WORKING_DIRECTORY ${__testname_dir})
  61. endforeach()
  62. # INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
  63. # message(STATUS "building tests:")
  64. #
  65. # ADD_EXECUTABLE( "cppunits_${the_library}" ../templates/cppUnitTestRunner.cpp ${nice_${the_library}_TESTFILES_SRC})
  66. # TARGET_LINK_LIBRARIES("cppunits_${the_library}" "nice_${the_library}" ${CPPUNIT_LIBRARIES} )
  67. #
  68. # INSTALL(TARGETS "cppunits_${the_library}" DESTINATION "tests/${the_library}")
  69. # SET_PROPERTY(TARGET "cppunits_${the_library}" PROPERTY FOLDER "unittests/${the_library}")
  70. # ADD_TEST("cppunits_${the_library}" "cppunits_${the_library}")
  71. endif()
  72. endmacro()