-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake support #20
Comments
+1 this would be nice to have! |
You can write CMakeLists.txt by yourself cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(glsl-parser LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Compiler flags
if (MSVC)
# MSVC-specific flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /EHs- /W4 /O2")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
else()
# Non-MSVC flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptoins -Wall -Wextra -Wformat -O3")
endif()
# Source files
set(SOURCES
ast.cpp
lexer.cpp
parser.cpp
util.cpp
)
# Header files
set(HEADERS
ast.h
lexemes.h
lexer.h
parser.h
util.h
)
# Static library target
add_library(${PROJECT_NAME} STATIC ${SOURCES})
# Public include directories
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
# MSVC-specific setting
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /permissive- /Zc:preprocessor /W4)
endif()
# Installation rules
include(GNUInstallDirs)
# Install the library
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Install the headers
install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
# Export the target for use by other projects
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE glsl-parser::
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, many thanks for all the work. Is there interest in the use of CMake? With CMake, the project will be more portable across different os and build systems.
The text was updated successfully, but these errors were encountered: