[vcpkg.json] Add cross-platform package management; [CMakeLists.txt] Use same compiler flags as example Makefile (sans C99); [example/CMakeLists.txt] WiP implementation; [cmake/modules/CMakeFindM.cmake] Find math library

This commit is contained in:
Samuel Marks 2022-05-24 22:32:50 -04:00
parent ec222c2e86
commit 0761cfc6c1
No known key found for this signature in database
GPG Key ID: 43FD8EDE42E1A799
4 changed files with 99 additions and 1 deletions

View File

@ -20,7 +20,7 @@ set(msvc "$<COMPILE_LANG_AND_ID:C,CXX,MSVC>")
target_compile_options(
"${PROJECT_NAME}_compiler_flags"
INTERFACE
"$<${gcc_like}:$<BUILD_INTERFACE:-Wno-shadow;-Wformat=2;-Wall;-Wno-gcc-compat;-Wno-c99-extensions>>"
"$<${gcc_like}:$<BUILD_INTERFACE:-Wall;-Wextra;-pedantic;-Wno-misleading-indentation;-Wno-shift-negative-value;-O2>>"
"$<${msvc}:$<BUILD_INTERFACE:-W3;-WX;-Zi;-permissive->>"
)
@ -43,8 +43,12 @@ configure_file(
#=============#
option(BUILD_HEADER_ONLY "Header only variant" "ON")
option(BUILD_EXAMPLES "Build examples" "ON")
add_subdirectory("src")
if (BUILD_EXAMPLES)
add_subdirectory("example")
endif (BUILD_EXAMPLES)
include(CTest)
if (BUILD_TESTING)

View File

@ -0,0 +1,53 @@
#
# - Find math
# Find the native M includes and library
#
# M_INCLUDE_DIRS - where to find math.h, etc.
# M_LIBRARIES - List of libraries when using math.
# M_FOUND - True if math found.
IF (M_INCLUDE_DIRS)
# Already in cache, be silent
SET(M_FIND_QUIETLY TRUE)
ENDIF (M_INCLUDE_DIRS)
#
# On OS X, make sure we do *NOT* find math.h in the Kernel framework,
# as that will convince CMake to cause the build to look there for
# headers.
#
# For some unknown reason, on Yosemite, math.h is included in the Kernel
# framework. That framework exists to supply headers for building
# *kernel* modules; it includes versions of C headers that are similar
# to the standard userland headers, but not similar enough to be usable
# when building userland code.
#
# Unless told not to look first in the framework paths, CMake will, on
# Yosemite, or when using the Yosemite SDK, find math.h in the Kernel
# framework, and add the header directory for the Kernel framework to
# the list of places to look for headers, causing it to pick up other
# headers from there as well. This causes the build to fail.
#
SET(SAVED_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
SET(CMAKE_FIND_FRAMEWORK LAST)
FIND_PATH(M_INCLUDE_DIR math.h)
SET(CMAKE_FIND_FRAMEWORK ${SAVED_CMAKE_FIND_FRAMEWORK})
SET(M_NAMES m)
FIND_LIBRARY(M_LIBRARY NAMES ${M_NAMES} )
# handle the QUIETLY and REQUIRED arguments and set M_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(M DEFAULT_MSG M_LIBRARY M_INCLUDE_DIR)
IF(M_FOUND)
SET( M_LIBRARIES ${M_LIBRARY} )
SET( M_INCLUDE_DIRS ${M_INCLUDE_DIR} )
ELSE(M_FOUND)
SET( M_LIBRARIES )
SET( M_INCLUDE_DIRS )
ENDIF(M_FOUND)
MARK_AS_ADVANCED( M_LIBRARIES M_INCLUDE_DIRS )

30
example/CMakeLists.txt Normal file
View File

@ -0,0 +1,30 @@
set(_libs "file_browser" "extended" "canvas" "skinning")
find_package(glfw3 CONFIG REQUIRED)
find_package(GLEW REQUIRED)
include(FindOpenGL)
find_package(OpenGL REQUIRED)
include("${CMAKE_SOURCE_DIR}/cmake/modules/CMakeFindM.cmake")
set(deps "glfw3" "GLEW::GLEW" "OpenGL::GL" "${M_LIBRARIES}")
if (APPLE)
#SET(GUI_TYPE MACOSX_BUNDLE)
#INCLUDE_DIRECTORIES ( /Developer/Headers/FlatCarbon )
find_library(COCOA_LIBRARY Cocoa)
find_library(COREVIDEO_LIBRARY CoreVideo)
find_library(IOKIT_LIBRARY IOKit)
mark_as_advanced(COCOA_LIBRARY COREVIDEO_LIBRARY IOKIT_LIBRARY)
list(APPEND deps "${COCOA_LIBRARY}" "${COREVIDEO_LIBRARY}" "${IOKIT_LIBRARY}")
# -L/usr/local/lib
# -I/usr/local/include
endif (APPLE)
foreach (_lib ${_libs})
set(src "${_lib}.c")
source_group("${_lib} Files" FILES "${src}")
add_executable("${_lib}" "${src}")
target_link_libraries("${_lib}" PRIVATE "${deps}")
target_include_directories("${_lib}" PRIVATE "${M_INCLUDE_DIRS}")
endforeach (_lib ${_libs})

11
vcpkg.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "nuklear",
"version-string": "0.0.1",
"port-version": 1,
"homepage": "https://github.com/Immediate-Mode-UI/Nuklear",
"description": "Minimal state immediate mode graphical user interface toolkit written in ANSI C and licensed under public domain.",
"dependencies": [
"glfw3",
"glew"
]
}