From 11c9f31d8da2cbf6f252e895b7a8f06fd0949151 Mon Sep 17 00:00:00 2001 From: Curtis Mahieu Date: Fri, 16 Sep 2016 16:29:39 -0700 Subject: [PATCH] Clean up CMake require c++11 standard --- CMakeLists.txt | 14 ++++++++++---- EtcLib/CMakeLists.txt | 13 ++++++++++--- EtcTool/CMakeLists.txt | 11 ++++------- EtcTool/EtcSourceImage.cpp | 3 ++- third_party/lodepng/CMakeLists.txt | 29 +++++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 third_party/lodepng/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a6392b..bbba4f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,15 +15,21 @@ cmake_minimum_required(VERSION 2.8.9) project(EtcTest) -set (CMAKE_CXX_STANDARD 11) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I/usr/include/i386-linux-gnu/c++/4.8 -I/usr/include/c++/4.8") + +SET(CMAKE_CXX_STANDARD 11) +SET(CXX_STANDARD_REQUIRED ON) + IF (APPLE) - set (CMAKE_CXX_FLAGS "-I/usr/include/i386-linux-gnu/c++/4.8 -I/usr/include/c++/4.8 -std=c++11 -g3 -Wall -O3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -O3") ELSE () IF (WIN32) - set (CMAKE_CXX_FLAGS "-I/usr/include/i386-linux-gnu/c++/4.8 -I/usr/include/c++/4.8 -W4 /EHsc") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W4 /EHsc") ELSE() - set (CMAKE_CXX_FLAGS "-I/usr/include/i386-linux-gnu/c++/4.8 -I/usr/include/c++/4.8 -std=c++11 -pthread -g3 -Wall -O2") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall") ENDIF() ENDIF () + +ADD_SUBDIRECTORY(third_party/lodepng) ADD_SUBDIRECTORY(EtcLib) ADD_SUBDIRECTORY(EtcTool) diff --git a/EtcLib/CMakeLists.txt b/EtcLib/CMakeLists.txt index b584b88..5ae433f 100644 --- a/EtcLib/CMakeLists.txt +++ b/EtcLib/CMakeLists.txt @@ -13,12 +13,19 @@ # limitations under the License. project(EtcLib) -include_directories(./Etc) -include_directories(./EtcCodec) + +set(INCLUDE_DIRS + "Etc" + "EtcCodec" +) + +include_directories(${INCLUDE_DIRS}) file(GLOB SOURCES ${PROJECT_SOURCE_DIR}/Etc/*.h ${PROJECT_SOURCE_DIR}/EtcCodec/*.h ${PROJECT_SOURCE_DIR}/Etc/*.cpp ${PROJECT_SOURCE_DIR}/EtcCodec/*.cpp) -ADD_LIBRARY(EtcLib ${SOURCES}) + +ADD_LIBRARY(${PROJECT_NAME} ${SOURCES}) +target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIRS}) diff --git a/EtcTool/CMakeLists.txt b/EtcTool/CMakeLists.txt index ef79cb0..693c536 100644 --- a/EtcTool/CMakeLists.txt +++ b/EtcTool/CMakeLists.txt @@ -13,16 +13,13 @@ # limitations under the License. project(EtcTool) -include_directories(../EtcLib/Etc) -include_directories(../EtcLib/EtcCodec) -include_directories(../third_party/lodepng) file(GLOB SOURCES ${PROJECT_SOURCE_DIR}/*.h ${PROJECT_SOURCE_DIR}/*.cpp - ../third_party/lodepng/*.h - ../third_party/lodepng/*.cpp) -add_executable(EtcTool ${SOURCES}) +) -target_link_libraries (EtcTool EtcLib) +add_executable(${PROJECT_NAME} ${SOURCES}) + +target_link_libraries(${PROJECT_NAME} EtcLib lodepng) diff --git a/EtcTool/EtcSourceImage.cpp b/EtcTool/EtcSourceImage.cpp index 0c64fea..21e9357 100644 --- a/EtcTool/EtcSourceImage.cpp +++ b/EtcTool/EtcSourceImage.cpp @@ -99,10 +99,11 @@ namespace Etc int iWidth; int iHeight; - int iBitsPerPixel; bool bool16BitImage = false; #if USE_STB_IMAGE_LOAD + int iBitsPerPixel; + //if stb_iamge is available, only use it to load files other than png char *fileExt = strrchr(m_pstrFilename, '.'); diff --git a/third_party/lodepng/CMakeLists.txt b/third_party/lodepng/CMakeLists.txt new file mode 100644 index 0000000..34d6856 --- /dev/null +++ b/third_party/lodepng/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright 2015 The Etc2Comp Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +project(lodepng) + +set(INCLUDE_DIRS + "." +) + +include_directories(${INCLUDE_DIRS}) + +file(GLOB SOURCES + "*.h" + "*.cpp" +) + +ADD_LIBRARY(${PROJECT_NAME} ${SOURCES}) +target_include_directories(${PROJECT_NAME} PUBLIC ${INCLUDE_DIRS})