summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt13
-rw-r--r--SetFlags.cmake191
-rw-r--r--Tools/MCADefrag/CMakeLists.txt6
-rw-r--r--lib/zlib/CMakeLists.txt14
4 files changed, 105 insertions, 119 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a42d8c599..8c8daf915 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,15 @@ cmake_minimum_required (VERSION 2.6)
# Without this, the MSVC variable isn't defined for MSVC builds ( http://www.cmake.org/pipermail/cmake/2011-November/047130.html )
enable_language(CXX C)
+#THis has to be done before any flags have been set up.
+if(${BUILD_TOOLS})
+ add_subdirectory(Tools/MCADefrag/)
+endif()
+
+if(${BUILD_UNSTABLE_TOOLS})
+ add_subdirectory(Tools/GeneratorPerformanceTest/)
+endif()
+
include(SetFlags.cmake)
set_flags()
set_lib_flags()
@@ -46,9 +55,5 @@ add_subdirectory(lib/polarssl/ EXCLUDE_FROM_ALL)
set_exe_flags()
-if(${BUILD_TOOLS})
-add_subdirectory(Tools/GeneratorPerformanceTest/)
-endif()
-
add_subdirectory (src)
diff --git a/SetFlags.cmake b/SetFlags.cmake
index a2f13384a..162560c90 100644
--- a/SetFlags.cmake
+++ b/SetFlags.cmake
@@ -23,9 +23,6 @@ endmacro()
macro(set_flags)
- if(NOT DEFINED ${FLAGS_SET})
- set(FLAGS_SET 1)
-
# Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
if (NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
@@ -88,121 +85,105 @@ macro(set_flags)
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
endif()
-
- endif()
endmacro()
macro(set_lib_flags)
- if(NOT DEFINED ${LIB_FLAGS_SET})
- set(LIB_FLAGS_SET 1)
- # Set lower warnings-level for the libraries:
- if (MSVC)
- # Remove /W3 from command line -- cannot just cancel it later with /w like in unix, MSVC produces a D9025 warning (option1 overriden by option2)
- string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- string(REPLACE "/W3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
- string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
- string(REPLACE "/W3" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
- else()
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -w")
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -w")
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -w")
- endif()
+ # Set lower warnings-level for the libraries:
+ if (MSVC)
+ # Remove /W3 from command line -- cannot just cancel it later with /w like in unix, MSVC produces a D9025 warning (option1 overriden by option2)
+ string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+ string(REPLACE "/W3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+ string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+ string(REPLACE "/W3" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+ else()
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -w")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -w")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -w")
+ endif()
- # On Unix we use two dynamic loading libraries dl and ltdl.
- # Preference is for dl on unknown systems as it is specified in POSIX
- # the dynamic loader is used by lua and sqllite.
- if (UNIX)
- if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
- set(DYNAMIC_LOADER ltdl)
- else()
- set(DYNAMIC_LOADER dl)
- endif()
+ # On Unix we use two dynamic loading libraries dl and ltdl.
+ # Preference is for dl on unknown systems as it is specified in POSIX
+ # the dynamic loader is used by lua and sqllite.
+ if (UNIX)
+ if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
+ set(DYNAMIC_LOADER ltdl)
+ else()
+ set(DYNAMIC_LOADER dl)
endif()
-
-
endif()
endmacro()
macro(enable_profile)
- if(NOT DEFINED ${PROFILE_ENABLED})
- set(PROFILE_ENABLED 1)
-
- # Declare the flags used for profiling builds:
- if (MSVC)
- set (CXX_PROFILING "")
- set (LNK_PROFILING "/PROFILE")
- else()
- set (CXX_PROFILING "-pg")
- set (LNK_PROFILING "-pg")
- endif()
+ # Declare the flags used for profiling builds:
+ if (MSVC)
+ set (CXX_PROFILING "")
+ set (LNK_PROFILING "/PROFILE")
+ else()
+ set (CXX_PROFILING "-pg")
+ set (LNK_PROFILING "-pg")
+ endif()
- # Declare the profiling configurations:
- SET(CMAKE_CXX_FLAGS_DEBUGPROFILE
- "${CMAKE_CXX_FLAGS_DEBUG} ${PCXX_ROFILING}"
- CACHE STRING "Flags used by the C++ compiler during profile builds."
- FORCE )
- SET(CMAKE_C_FLAGS_DEBUGPROFILE
- "${CMAKE_C_FLAGS_DEBUG} ${CXX_PROFILING}"
- CACHE STRING "Flags used by the C compiler during profile builds."
- FORCE )
- SET(CMAKE_EXE_LINKER_FLAGS_DEBUGPROFILE
- "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${LNK_PROFILING}"
- CACHE STRING "Flags used for linking binaries during profile builds."
- FORCE )
- SET(CMAKE_SHARED_LINKER_FLAGS_DEBUGPROFILE
- "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${LNK_PROFILING}"
- CACHE STRING "Flags used by the shared libraries linker during profile builds."
- FORCE )
- MARK_AS_ADVANCED(
- CMAKE_CXX_FLAGS_DEBUGPROFILE
- CMAKE_C_FLAGS_DEBUGPROFILE
- CMAKE_EXE_LINKER_FLAGS_DEBUGPROFILE
- CMAKE_SHARED_LINKER_FLAGS_DEBUGPROFILE )
-
- SET(CMAKE_CXX_FLAGS_RELEASEPROFILE
- "${CMAKE_CXX_FLAGS_RELEASE} ${CXX_PROFILING}"
- CACHE STRING "Flags used by the C++ compiler during profile builds."
- FORCE )
- SET(CMAKE_C_FLAGS_RELEASEPROFILE
- "${CMAKE_C_FLAGS_RELEASE} ${CXX_PROFILING}"
- CACHE STRING "Flags used by the C compiler during profile builds."
- FORCE )
- SET(CMAKE_EXE_LINKER_FLAGS_RELEASEPROFILE
- "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${LNK_PROFILING}"
- CACHE STRING "Flags used for linking binaries during profile builds."
- FORCE )
- SET(CMAKE_SHARED_LINKER_FLAGS_RELEASEPROFILE
- "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${LNK_PROFILING}"
- CACHE STRING "Flags used by the shared libraries linker during profile builds."
- FORCE )
- MARK_AS_ADVANCED(
- CMAKE_CXX_FLAGS_RELEASEPROFILE
- CMAKE_C_FLAGS_RELEASEPROFILE
- CMAKE_EXE_LINKER_FLAGS_RELEASEPROFILE
- CMAKE_SHARED_LINKER_FLAGS_RELEASEPROFILE )
- # The configuration types need to be set after their respective c/cxx/linker flags and before the project directive
- set(CMAKE_CONFIGURATION_TYPES "Debug;Release;DebugProfile;ReleaseProfile" CACHE STRING "" FORCE)
- endif()
+ # Declare the profiling configurations:
+ SET(CMAKE_CXX_FLAGS_DEBUGPROFILE
+ "${CMAKE_CXX_FLAGS_DEBUG} ${PCXX_ROFILING}"
+ CACHE STRING "Flags used by the C++ compiler during profile builds."
+ FORCE )
+ SET(CMAKE_C_FLAGS_DEBUGPROFILE
+ "${CMAKE_C_FLAGS_DEBUG} ${CXX_PROFILING}"
+ CACHE STRING "Flags used by the C compiler during profile builds."
+ FORCE )
+ SET(CMAKE_EXE_LINKER_FLAGS_DEBUGPROFILE
+ "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${LNK_PROFILING}"
+ CACHE STRING "Flags used for linking binaries during profile builds."
+ FORCE )
+ SET(CMAKE_SHARED_LINKER_FLAGS_DEBUGPROFILE
+ "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${LNK_PROFILING}"
+ CACHE STRING "Flags used by the shared libraries linker during profile builds."
+ FORCE )
+ MARK_AS_ADVANCED(
+ CMAKE_CXX_FLAGS_DEBUGPROFILE
+ CMAKE_C_FLAGS_DEBUGPROFILE
+ CMAKE_EXE_LINKER_FLAGS_DEBUGPROFILE
+ CMAKE_SHARED_LINKER_FLAGS_DEBUGPROFILE )
+
+ SET(CMAKE_CXX_FLAGS_RELEASEPROFILE
+ "${CMAKE_CXX_FLAGS_RELEASE} ${CXX_PROFILING}"
+ CACHE STRING "Flags used by the C++ compiler during profile builds."
+ FORCE )
+ SET(CMAKE_C_FLAGS_RELEASEPROFILE
+ "${CMAKE_C_FLAGS_RELEASE} ${CXX_PROFILING}"
+ CACHE STRING "Flags used by the C compiler during profile builds."
+ FORCE )
+ SET(CMAKE_EXE_LINKER_FLAGS_RELEASEPROFILE
+ "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${LNK_PROFILING}"
+ CACHE STRING "Flags used for linking binaries during profile builds."
+ FORCE )
+ SET(CMAKE_SHARED_LINKER_FLAGS_RELEASEPROFILE
+ "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${LNK_PROFILING}"
+ CACHE STRING "Flags used by the shared libraries linker during profile builds."
+ FORCE )
+ MARK_AS_ADVANCED(
+ CMAKE_CXX_FLAGS_RELEASEPROFILE
+ CMAKE_C_FLAGS_RELEASEPROFILE
+ CMAKE_EXE_LINKER_FLAGS_RELEASEPROFILE
+ CMAKE_SHARED_LINKER_FLAGS_RELEASEPROFILE )
+ # The configuration types need to be set after their respective c/cxx/linker flags and before the project directive
+ set(CMAKE_CONFIGURATION_TYPES "Debug;Release;DebugProfile;ReleaseProfile" CACHE STRING "" FORCE)
endmacro()
macro(set_exe_flags)
- if(NOT DEFINED ${EXE_FLAGS_SET})
- set(EXE_FLAGS_SET 1)
-
- # Remove disabling the maximum warning level:
- # clang does not like a command line that reads -Wall -Wextra -w -Wall -Wextra and does not output any warnings
- # We do not do that for MSVC since MSVC produces an awful lot of warnings for its own STL headers;
- # the important warnings are turned on using #pragma in Globals.h
- if (NOT MSVC)
- string(REPLACE "-w" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- string(REPLACE "-w" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
- string(REPLACE "-w" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
- string(REPLACE "-w" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
- add_flags_cxx("-Wall")
- endif()
-
-
+ # Remove disabling the maximum warning level:
+ # clang does not like a command line that reads -Wall -Wextra -w -Wall -Wextra and does not output any warnings
+ # We do not do that for MSVC since MSVC produces an awful lot of warnings for its own STL headers;
+ # the important warnings are turned on using #pragma in Globals.h
+ if (NOT MSVC)
+ string(REPLACE "-w" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+ string(REPLACE "-w" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+ string(REPLACE "-w" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+ string(REPLACE "-w" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+ add_flags_cxx("-Wall")
endif()
+
endmacro()
diff --git a/Tools/MCADefrag/CMakeLists.txt b/Tools/MCADefrag/CMakeLists.txt
index 174da4fab..c11c8c772 100644
--- a/Tools/MCADefrag/CMakeLists.txt
+++ b/Tools/MCADefrag/CMakeLists.txt
@@ -30,10 +30,8 @@ endfunction()
# Include the libraries:
-if(NOT DEFINED ${ZLIB})
- add_subdirectory(../../lib/zlib lib/zlib)
- set(ZLIB 1)
-endif()
+
+add_subdirectory(../../lib/zlib lib/zlib)
set_exe_flags()
diff --git a/lib/zlib/CMakeLists.txt b/lib/zlib/CMakeLists.txt
index b1b74031d..6c52578ee 100644
--- a/lib/zlib/CMakeLists.txt
+++ b/lib/zlib/CMakeLists.txt
@@ -8,12 +8,14 @@ file(GLOB SOURCE
"*.c"
)
-add_library(zlib ${SOURCE})
+if(NOT TARGET zlib)
+ add_library(zlib ${SOURCE})
-if (MSVC)
- # Remove SCL warnings, we expect this library to have been tested safe
- SET_TARGET_PROPERTIES(
- zlib PROPERTIES COMPILE_FLAGS "-D_CRT_SECURE_NO_WARNINGS"
- )
+ if (MSVC)
+ # Remove SCL warnings, we expect this library to have been tested safe
+ SET_TARGET_PROPERTIES(
+ zlib PROPERTIES COMPILE_FLAGS "-D_CRT_SECURE_NO_WARNINGS"
+ )
+ endif()
endif()