ProjectCommon.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ## ProjectCommon.cmake
  2. # Centralized CMake settings used across the V-Gears project.
  3. # Build verbosity default (can be overridden by caller)
  4. if(NOT DEFINED CMAKE_VERBOSE_MAKEFILE)
  5. set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Enable verbose makefile output" FORCE)
  6. endif()
  7. # C++ standard and basic compile settings
  8. if(NOT DEFINED CMAKE_CXX_STANDARD)
  9. set(CMAKE_CXX_STANDARD 14)
  10. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  11. endif()
  12. # Produce position independent code by default where relevant
  13. set(CMAKE_POSITION_INDEPENDENT_CODE ON)
  14. # Debug postfix for libraries
  15. if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
  16. set(CMAKE_DEBUG_POSTFIX "_d")
  17. endif()
  18. # Multi-config generators should use generator expressions; for single-config
  19. # generators provide per-configuration output folders as a convenience.
  20. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  21. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/lib)
  22. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/lib)
  23. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin_debug)
  24. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin_debug/lib)
  25. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin_debug/lib)
  26. # Enable folders in IDEs like Visual Studio
  27. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  28. # Make sure our custom CMake modules are discoverable (already appended by top-level)
  29. list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
  30. # Create directory for generated headers
  31. file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/generated")
  32. ## Helper: install default GNUInstallDirs if not available
  33. include(GNUInstallDirs OPTIONAL)
  34. # Policy: prefer modern targets if project transitions to target-based linking.