NiceModules.cmake 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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} ${Boost_LIBRARIES} ${OPENGL_LIBRARY} ${GLUT_LIBRARY} ${QT_LIBRARIES})
  23. SET_PROPERTY(TARGET "nice_${the_library}" PROPERTY FOLDER "library")
  24. INSTALL(TARGETS "nice_${the_library}" DESTINATION lib)
  25. endmacro()
  26. #using variables "the_library"
  27. #and subvariables ${nice_${the_library}_PROGFILES_SRC}
  28. macro(nice_add_progs)
  29. if(BUILD_CORE_PROGS)
  30. message(STATUS "building progs:")
  31. foreach(__progcpp ${nice_${the_library}_PROGFILES_SRC})
  32. get_filename_component(__progname ${__progcpp} NAME_WE )
  33. message(STATUS "progname: ${__progname} ${__progcpp}")
  34. set(prog_target_name "${the_library}_${__progname}")
  35. ADD_EXECUTABLE( ${prog_target_name} ${__progcpp})
  36. TARGET_LINK_LIBRARIES(${prog_target_name} "nice_${the_library}")
  37. SET_TARGET_PROPERTIES(${prog_target_name} PROPERTIES OUTPUT_NAME "${__progname}")
  38. INSTALL(TARGETS ${prog_target_name} DESTINATION "bin/${the_library}")
  39. SET_PROPERTY(TARGET ${prog_target_name} PROPERTY FOLDER "programs/${the_library}")
  40. endforeach()
  41. endif()
  42. endmacro()
  43. #using variables "the_library"
  44. #and subvariables ${nice_${the_library}_TESTFILES_SRC}
  45. macro(nice_add_unittests)
  46. if(BUILD_CORE_TESTS)
  47. INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
  48. message(STATUS "building tests:")
  49. foreach(__testcpp ${nice_${the_library}_TESTFILES_SRC})
  50. get_filename_component(__testname ${__testcpp} NAME_WE )
  51. message(STATUS "unittest: ${__testname} ${__testcpp}")
  52. ADD_EXECUTABLE( ${__testname} ../templates/cppUnitTestRunner.cpp ${__testcpp})
  53. TARGET_LINK_LIBRARIES(${__testname} "nice_${the_library}" ${CPPUNIT_LIBRARIES} )
  54. INSTALL(TARGETS ${__testname} DESTINATION "tests/${the_library}")
  55. SET_PROPERTY(TARGET ${__testname} PROPERTY FOLDER "unittests/${the_library}")
  56. ADD_TEST(${__testname} ${__testname})
  57. endforeach()
  58. endif()
  59. endmacro()