CMakeLists.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # This build script is not meant for general use, it is for CI use only!
  2. cmake_minimum_required(VERSION 3.0)
  3. project(implot)
  4. #
  5. # Global options
  6. #
  7. # Same as Dear ImGui
  8. set(CMAKE_CXX_STANDARD 11)
  9. # Arch option for linux
  10. if (NOT APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" AND DEFINED GCC_ARCH)
  11. if ("${GCC_ARCH}" MATCHES "Win32|x86|32")
  12. add_compile_options(-m32)
  13. add_link_options(-m32)
  14. elseif ("${GCC_ARCH}" MATCHES "Win64|x64|64")
  15. add_compile_options(-m64)
  16. add_link_options(-m64)
  17. endif ()
  18. endif ()
  19. # Arch option for Mac: arm64 for M1 or x86_64 for intel (32 bits build are deprecated on Mac)
  20. if(APPLE AND DEFINED OSX_ARCH)
  21. if ("${OSX_ARCH}" MATCHES "x86_64")
  22. set(CMAKE_OSX_ARCHITECTURES "x86_64")
  23. elseif ("${OSX_ARCH}" MATCHES "arm64")
  24. set(CMAKE_OSX_ARCHITECTURES "arm64")
  25. else()
  26. message(FATAL_ERROR "Unhandled OSX_ARCH=${OSX_ARCH}")
  27. endif()
  28. endif()
  29. #
  30. # Dear ImGui library with no backend
  31. #
  32. set(imgui_sources
  33. ../imgui/imconfig.h
  34. ../imgui/imgui.cpp
  35. ../imgui/imgui.h
  36. ../imgui/imgui_demo.cpp
  37. ../imgui/imgui_draw.cpp
  38. ../imgui/imgui_internal.h
  39. ../imgui/imgui_tables.cpp
  40. ../imgui/imgui_widgets.cpp
  41. ../imgui/imstb_rectpack.h
  42. ../imgui/imstb_textedit.h
  43. ../imgui/imstb_truetype.h
  44. )
  45. add_library(imgui ${imgui_sources})
  46. target_include_directories(imgui PUBLIC ../imgui)
  47. #
  48. # ImPlot library
  49. #
  50. file(GLOB SOURCE_CODE ../implot*.*)
  51. add_library(implot STATIC ${SOURCE_CODE})
  52. if(MSVC)
  53. target_compile_options(implot PRIVATE /W4 /WX)
  54. else()
  55. target_compile_options(implot PRIVATE -Wall -Werror -pedantic)
  56. endif()
  57. target_include_directories(implot PUBLIC ${CMAKE_CURRENT_LIST_DIR}/..)
  58. target_link_libraries(implot PUBLIC imgui)
  59. if (UNIX)
  60. target_link_libraries(implot PUBLIC m stdc++)
  61. endif()
  62. # Define supported types via command line:
  63. # - With no choice all types are supported (so that the CI provides support for all known types)
  64. # - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="default" the default set defined in implot_items.cpp is used
  65. # - with -DIMPLOT_CUSTOM_NUMERIC_TYPES="(int)(float)(double)" only int, float and double are supported
  66. if (NOT DEFINED IMPLOT_CUSTOM_NUMERIC_TYPES)
  67. set(IMPLOT_CUSTOM_NUMERIC_TYPES "all")
  68. endif()
  69. if ("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "default")
  70. message("==== Compiling for default types ====")
  71. elseif("${IMPLOT_CUSTOM_NUMERIC_TYPES}" STREQUAL "all")
  72. message("==== Compiling for all types ====")
  73. target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=(signed char)(unsigned char)(signed short)(unsigned short)(signed int)(unsigned int)(signed long)(unsigned long)(signed long long)(unsigned long long)(float)(double)(long double)")
  74. else()
  75. message("==== Compiling for custom types: ${IMPLOT_CUSTOM_NUMERIC_TYPES} ====")
  76. target_compile_definitions(implot PRIVATE "IMPLOT_CUSTOM_NUMERIC_TYPES=${IMPLOT_CUSTOM_NUMERIC_TYPES}")
  77. endif()
  78. #
  79. # implot example binary application (with no backend)
  80. #
  81. add_executable(example_implot example_implot.cpp)
  82. target_link_libraries(example_implot PRIVATE implot)