diff --git a/CMakeLists.txt b/CMakeLists.txt index db87754e..c71f869b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,6 @@ if (WIN32) set(WIN32_PTHREADS_INCLUDE_PATH "${WIN32_PTHREADS_PATH}/include") endif() -# Always look. It won't be found on Windows. Later build scripts will understand how to -# WAR it being missing. -find_package(TinyXML) - message("") message("cmake options:") message(" -DCMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}': Build debug or release. (Debug|Release)") diff --git a/src/build_options.cmake b/src/build_options.cmake index 33fa3bc7..3c44da8a 100644 --- a/src/build_options.cmake +++ b/src/build_options.cmake @@ -382,24 +382,22 @@ function(require_libjpegturbo) PATHS /opt/libjpeg-turbo/lib ) - # On platforms that find this, the include files will have also been installed to the system - # so we don't need extra include dirs. - if (LibJpegTurbo_LIBRARY) - set(LibJpegTurbo_INCLUDE "" PARENT_SCOPE) + IF(LibJpegTurbo_LIBRARY) + find_path(LibJpegTurbo_INCLUDE_DIR + NAME turbojpeg.h + PATHS /opt/libjpeg-turbo/inc /opt/libjpeg-turbo/include + ) + IF(NOT LibJpegTurbo_INCLUDE_DIR) + message(FATAL_ERROR "Unable to find turbojpeg.h") + ENDIF() + set(LibJpegTurbo_INCLUDE "${LibJpegTurbo_INCLUDE_DIR}" PARENT_SCOPE) # On Darwin we assume a Homebrew install elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(LibJpegTurbo_INCLUDE "/usr/local/opt/jpeg-turbo/include" PARENT_SCOPE) set(LibJpegTurbo_LIBRARY "/usr/local/opt/jpeg-turbo/lib/libturbojpeg.a" PARENT_SCOPE) - else() - if (BUILD_X64) - set(BITS_STRING "x64") - else() - set(BITS_STRING "x86") - endif() - set(LibJpegTurbo_INCLUDE "${CMAKE_PREFIX_PATH}/libjpeg-turbo-2.1.3/include" PARENT_SCOPE) - set(LibJpegTurbo_LIBRARY "${CMAKE_PREFIX_PATH}/libjpeg-turbo-2.1.3/lib_${BITS_STRING}/turbojpeg.lib" PARENT_SCOPE) + message(FATAL_ERROR "Unable to find libturbojpeg.so") endif() endfunction() diff --git a/src/cmake/Modules/FindTinyXML.cmake b/src/cmake/Modules/FindTinyXML.cmake deleted file mode 100644 index 32221602..00000000 --- a/src/cmake/Modules/FindTinyXML.cmake +++ /dev/null @@ -1,75 +0,0 @@ -################################################################################################## -# -# CMake script for finding TinyXML. -# -# Input variables: -# -# - TinyXML_ROOT_DIR (optional): When specified, header files and libraries will be searched for in -# ${TinyXML_ROOT_DIR}/include -# ${TinyXML_ROOT_DIR}/libs -# respectively, and the default CMake search order will be ignored. When unspecified, the default -# CMake search order is used. -# This variable can be specified either as a CMake or environment variable. If both are set, -# preference is given to the CMake variable. -# Use this variable for finding packages installed in a nonstandard location, or for enforcing -# that one of multiple package installations is picked up. -# -# -# Cache variables (not intended to be used in CMakeLists.txt files) -# -# - TinyXML_INCLUDE_DIR: Absolute path to package headers. -# - TinyXML_LIBRARY: Absolute path to library. -# -# -# Output variables: -# -# - TinyXML_FOUND: Boolean that indicates if the package was found -# - TinyXML_INCLUDE_DIRS: Paths to the necessary header files -# - TinyXML_LIBRARIES: Package libraries -# -# -# Example usage: -# -# find_package(TinyXML) -# if(NOT TinyXML_FOUND) -# # Error handling -# endif() -# ... -# include_directories(${TinyXML_INCLUDE_DIRS} ...) -# ... -# target_link_libraries(my_target ${TinyXML_LIBRARIES}) -# -################################################################################################## -#from: https://github.com/ros/cmake_modules/blob/0.3-devel/cmake/Modules/FindTinyXML.cmake - -# Get package location hint from environment variable (if any) -if(NOT TinyXML_ROOT_DIR AND DEFINED ENV{TinyXML_ROOT_DIR}) - set(TinyXML_ROOT_DIR "$ENV{TinyXML_ROOT_DIR}" CACHE PATH - "TinyXML base directory location (optional, used for nonstandard installation paths)") -endif() - -# Search path for nonstandard package locations -if(TinyXML_ROOT_DIR) - set(TinyXML_INCLUDE_PATH PATHS "${TinyXML_ROOT_DIR}/include" NO_DEFAULT_PATH) - set(TinyXML_LIBRARY_PATH PATHS "${TinyXML_ROOT_DIR}/lib" NO_DEFAULT_PATH) -endif() - -# Find headers and libraries -find_path(TinyXML_INCLUDE_DIR NAMES tinyxml.h PATH_SUFFIXES "tinyxml" ${TinyXML_INCLUDE_PATH}) -find_library(TinyXML_LIBRARY NAMES tinyxml PATH_SUFFIXES "tinyxml" ${TinyXML_LIBRARY_PATH}) - -mark_as_advanced(TinyXML_INCLUDE_DIR - TinyXML_LIBRARY) - -# Output variables generation -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(TinyXML DEFAULT_MSG TinyXML_LIBRARY - TinyXML_INCLUDE_DIR) - -set(TinyXML_FOUND ${TINYXML_FOUND}) # Enforce case-correctness: Set appropriately cased variable... -unset(TINYXML_FOUND) # ...and unset uppercase variable generated by find_package_handle_standard_args - -if(TinyXML_FOUND) - set(TinyXML_INCLUDE_DIRS ${TinyXML_INCLUDE_DIR}) - set(TinyXML_LIBRARIES ${TinyXML_LIBRARY}) -endif() diff --git a/src/cmake/Modules/FindTinyXML2.cmake b/src/cmake/Modules/FindTinyXML2.cmake new file mode 100644 index 00000000..23dd6227 --- /dev/null +++ b/src/cmake/Modules/FindTinyXML2.cmake @@ -0,0 +1,75 @@ +################################################################################################## +# +# CMake script for finding TinyXML2. +# +# Input variables: +# +# - TinyXML2_ROOT_DIR (optional): When specified, header files and libraries will be searched for in +# ${TinyXML2_ROOT_DIR}/include +# ${TinyXML2_ROOT_DIR}/libs +# respectively, and the default CMake search order will be ignored. When unspecified, the default +# CMake search order is used. +# This variable can be specified either as a CMake or environment variable. If both are set, +# preference is given to the CMake variable. +# Use this variable for finding packages installed in a nonstandard location, or for enforcing +# that one of multiple package installations is picked up. +# +# +# Cache variables (not intended to be used in CMakeLists.txt files) +# +# - TinyXML2_INCLUDE_DIR: Absolute path to package headers. +# - TinyXML2_LIBRARY: Absolute path to library. +# +# +# Output variables: +# +# - TinyXML2_FOUND: Boolean that indicates if the package was found +# - TinyXML2_INCLUDE_DIRS: Paths to the necessary header files +# - TinyXML2_LIBRARIES: Package libraries +# +# +# Example usage: +# +# find_package(TinyXML2) +# if(NOT TinyXML2_FOUND) +# # Error handling +# endif() +# ... +# include_directories(${TinyXML2_INCLUDE_DIRS} ...) +# ... +# target_link_libraries(my_target ${TinyXML2_LIBRARIES}) +# +################################################################################################## +#from: https://github.com/ros/cmake_modules/blob/0.3-devel/cmake/Modules/FindTinyXML.cmake + +# Get package location hint from environment variable (if any) +if(NOT TinyXML2_ROOT_DIR AND DEFINED ENV{TinyXML2_ROOT_DIR}) + set(TinyXML2_ROOT_DIR "$ENV{TinyXML2_ROOT_DIR}" CACHE PATH + "TinyXML2 base directory location (optional, used for nonstandard installation paths)") +endif() + +# Search path for nonstandard package locations +if(TinyXML2_ROOT_DIR) + set(TinyXML2_INCLUDE_PATH PATHS "${TinyXML2_ROOT_DIR}/include" NO_DEFAULT_PATH) + set(TinyXML2_LIBRARY_PATH PATHS "${TinyXML2_ROOT_DIR}/lib" NO_DEFAULT_PATH) +endif() + +# Find headers and libraries +find_path(TinyXML2_INCLUDE_DIR NAMES tinyxml2.h PATH_SUFFIXES "tinyxml" ${TinyXML2_INCLUDE_PATH}) +find_library(TinyXML2_LIBRARY NAMES tinyxml2 PATH_SUFFIXES "tinyxml" ${TinyXML2_LIBRARY_PATH}) + +mark_as_advanced(TinyXML2_INCLUDE_DIR + TinyXML2_LIBRARY) + +# Output variables generation +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TinyXML2_LIBRARY + TinyXML2_INCLUDE_DIR) + +set(TinyXML2_FOUND ${TINYXML2_FOUND}) # Enforce case-correctness: Set appropriately cased variable... +unset(TINYXML2_FOUND) # ...and unset uppercase variable generated by find_package_handle_standard_args + +if(TinyXML2_FOUND) + set(TinyXML2_INCLUDE_DIRS ${TinyXML2_INCLUDE_DIR}) + set(TinyXML2_LIBRARIES ${TinyXML2_LIBRARY}) +endif() diff --git a/src/voglgen/CMakeLists.txt b/src/voglgen/CMakeLists.txt index e57d566f..e31f8c60 100644 --- a/src/voglgen/CMakeLists.txt +++ b/src/voglgen/CMakeLists.txt @@ -5,30 +5,36 @@ include("${SRC_DIR}/build_options.cmake") require_pthreads() -file( GLOB_RECURSE HDRS *.[h|inl] ) - set(SPEC_DIR "${SRC_DIR}/../glspec") +# Always look. It won't be found on Windows. Later build scripts will +# understand how to WAR it being missing. +find_package(TinyXML2) + +if (NOT TinyXML2_FOUND) + message(WARNING "TinyXML2 Not Found; will build it.") + add_library( tinyxml2 STATIC tinyxml2/tinyxml2.cpp tinyxml2/tinyxml2.h ) + + set( TinyXML2_LIBRARIES tinyxml2 ) + set( TinyXML2_INCLUDE_DIR tinyxml2 ) +endif() + file( GLOB SPECS "${SPEC_DIR}/*.spec" "${SPEC_DIR}/*.tm" "${SPEC_DIR}/*.xml" ) -set(SRC_LIST ${HDRS} ${SPECS} - voglgen.cpp - tinyxml2/tinyxml2.cpp) +set(SRC_LIST ${SPECS} voglgen.cpp) # Add a source group to easily look at the spec files. if (MSVC) SOURCE_GROUP( "Specs Files" FILES ${SPECS} ) endif() -add_definitions(-DTIXML_USE_STL) - include_directories( - ${SRC_DIR}/voglcore + ${SRC_DIR}/voglcore ${TinyXML2_INCLUDES} ) add_executable(${PROJECT_NAME} ${SRC_LIST}) target_link_libraries(${PROJECT_NAME} - voglcore + ${TinyXML2_LIBRARIES} voglcore ) set(FORCE_REGENERATE ${SPEC_DIR}/force_regenerate)