* Use `GNUInstallDirs` in order to respect GNU conventions.
  This is especially important for multi-arch/multi-lib setups.
* Specify position independent mode building properly, without
  using the historic hack of adding `-fPIC` as a definition.
  This makes the build system more portable.
* Only detect C++ (and not C) to slightly speed up configuring.
* Specify C++11 mode using modern CMake idioms.
* Fix some whitespace issues.
This commit is contained in:
David Seifert 2017-04-28 22:46:52 +02:00
Родитель acce8dce1b
Коммит 5a5699bdbd
10 изменённых файлов: 130 добавлений и 126 удалений

Просмотреть файл

@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 2.8.11)
# increase to 3.1 once all major distributions
# include a version of CMake >= 3.1
cmake_minimum_required(VERSION 2.8.12)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Adhere to GNU filesystem layout conventions
include(GNUInstallDirs)
option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
@ -8,10 +13,6 @@ option(ENABLE_NV_EXTENSIONS "Enables support of Nvidia-specific extensions" ON)
option(ENABLE_HLSL "Enables HLSL input support" ON)
enable_testing()
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix")
project(glslang)
if(ENABLE_AMD_EXTENSIONS)
@ -33,33 +34,39 @@ if(WIN32)
endif(MSVC)
add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
elseif(UNIX)
add_definitions(-fPIC)
add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
else(WIN32)
message("unknown platform")
endif(WIN32)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
add_compile_options(-Wall -Wmaybe-uninitialized -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable -Wunused-but-set-parameter -Wunused-but-set-variable)
add_definitions(-Wno-reorder) # disable this from -Wall, since it happens all over.
add_definitions(-std=c++11)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_definitions(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
add_compile_options(-Wall -Wuninitialized -Wunused -Wunused-local-typedefs
-Wunused-parameter -Wunused-value -Wunused-variable)
add_definitions(-Wno-reorder) # disable this from -Wall, since it happens all over.
add_definitions(-std=c++11)
add_compile_options(-Wno-reorder) # disable this from -Wall, since it happens all over.
endif()
# Request C++11
if(${CMAKE_VERSION} VERSION_LESS 3.1)
# CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD
# remove this block once CMake >=3.1 has fixated in the ecosystem
add_compile_options(-std=c++11)
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
function(glslang_set_link_args TARGET)
# For MinGW compiles, statically link against the GCC and C++ runtimes.
# This avoids the need to ship those runtimes as DLLs.
if(WIN32)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
set_target_properties(${TARGET} PROPERTIES
LINK_FLAGS "-static -static-libgcc -static-libstdc++")
endif()
endif(WIN32)
endfunction(glslang_set_link_args)
# We depend on these for later projects, so they should come first.

3
External/CMakeLists.txt поставляемый
Просмотреть файл

@ -14,8 +14,7 @@ elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
gtest
gtest_main
gmock
gmock_main
)
gmock_main)
foreach(target ${GTEST_TARGETS})
set_property(TARGET ${target} PROPERTY FOLDER gtest)
endforeach()

Просмотреть файл

@ -1,11 +1,11 @@
set(SOURCES InitializeDll.cpp InitializeDll.h)
add_library(OGLCompiler STATIC ${SOURCES})
set_property(TARGET OGLCompiler PROPERTY FOLDER glslang)
set_property(TARGET OGLCompiler PROPERTY FOLDER glslang POSITION_INDEPENDENT_CODE ON)
if(WIN32)
source_group("Source" FILES ${SOURCES})
endif(WIN32)
install(TARGETS OGLCompiler
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

Просмотреть файл

@ -40,11 +40,11 @@ if(ENABLE_NV_EXTENSIONS)
endif(ENABLE_NV_EXTENSIONS)
add_library(SPIRV STATIC ${SOURCES} ${HEADERS})
set_property(TARGET SPIRV PROPERTY FOLDER glslang)
set_property(TARGET SPIRV PROPERTY FOLDER glslang POSITION_INDEPENDENT_CODE ON)
target_link_libraries(SPIRV glslang)
add_library(SPVRemapper STATIC ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
set_property(TARGET SPVRemapper PROPERTY FOLDER glslang POSITION_INDEPENDENT_CODE ON)
if(WIN32)
source_group("Source" FILES ${SOURCES} ${HEADERS})
@ -52,6 +52,6 @@ if(WIN32)
endif(WIN32)
install(TARGETS SPIRV SPVRemapper
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION include/SPIRV/)
install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SPIRV/)

Просмотреть файл

@ -1,12 +1,10 @@
add_library(glslang-default-resource-limits
${CMAKE_CURRENT_SOURCE_DIR}/ResourceLimits.cpp
)
set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER glslang)
${CMAKE_CURRENT_SOURCE_DIR}/ResourceLimits.cpp)
set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER glslang POSITION_INDEPENDENT_CODE ON)
target_include_directories(glslang-default-resource-limits
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC ${PROJECT_SOURCE_DIR}
)
PUBLIC ${PROJECT_SOURCE_DIR})
set(SOURCES StandAlone.cpp)
set(REMAPPER_SOURCES spirv-remap.cpp)
@ -41,7 +39,7 @@ if(WIN32)
endif(WIN32)
install(TARGETS glslangValidator
RUNTIME DESTINATION bin)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS spirv-remap
RUNTIME DESTINATION bin)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Просмотреть файл

@ -81,7 +81,7 @@ set(HEADERS
# set(BISON_GLSLParser_OUTPUT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/MachineIndependent/glslang_tab.cpp)
add_library(glslang STATIC ${BISON_GLSLParser_OUTPUT_SOURCE} ${SOURCES} ${HEADERS})
set_property(TARGET glslang PROPERTY FOLDER glslang)
set_property(TARGET glslang PROPERTY FOLDER glslang POSITION_INDEPENDENT_CODE ON)
target_link_libraries(glslang OGLCompiler OSDependent)
if(ENABLE_HLSL)
target_link_libraries(glslang HLSL)
@ -96,9 +96,9 @@ if(WIN32)
endif(WIN32)
install(TARGETS glslang
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
foreach(file ${HEADERS})
get_filename_component(dir ${file} DIRECTORY)
install(FILES ${file} DESTINATION include/glslang/${dir})
install(FILES ${file} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/glslang/${dir})
endforeach()

Просмотреть файл

@ -1,5 +1,5 @@
add_library(OSDependent STATIC ossource.cpp ../osinclude.h)
set_property(TARGET OSDependent PROPERTY FOLDER glslang)
set_property(TARGET OSDependent PROPERTY FOLDER glslang POSITION_INDEPENDENT_CODE ON)
install(TARGETS OSDependent
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

Просмотреть файл

@ -1,7 +1,7 @@
set(SOURCES ossource.cpp ../osinclude.h)
add_library(OSDependent STATIC ${SOURCES})
set_property(TARGET OSDependent PROPERTY FOLDER glslang)
set_property(TARGET OSDependent PROPERTY FOLDER glslang POSITION_INDEPENDENT_CODE ON)
# MinGW GCC complains about function pointer casts to void*.
# Turn that off with -fpermissive.
@ -14,4 +14,4 @@ if(WIN32)
endif(WIN32)
install(TARGETS OSDependent
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

Просмотреть файл

@ -20,15 +20,15 @@ if (TARGET gmock)
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp
# -- Remapper tests
${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp
)
${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
add_executable(glslangtests ${TEST_SOURCES})
set_property(TARGET glslangtests PROPERTY FOLDER tests)
glslang_set_link_args(glslangtests)
install(TARGETS glslangtests
RUNTIME DESTINATION bin)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
# Supply a default test root directory, so that manual testing

Просмотреть файл

@ -18,11 +18,11 @@ set(SOURCES
hlslParseables.h)
add_library(HLSL STATIC ${SOURCES} ${HEADERS})
set_property(TARGET HLSL PROPERTY FOLDER hlsl)
set_property(TARGET HLSL PROPERTY FOLDER hlsl POSITION_INDEPENDENT_CODE ON)
if(WIN32)
source_group("Source" FILES ${SOURCES} ${HEADERS})
endif(WIN32)
install(TARGETS HLSL
ARCHIVE DESTINATION lib)
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})