# Copyright (c) <2014> # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. # # Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely. cmake_minimum_required(VERSION 2.8.8) project(NewtonSDK) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) # Use relative paths # This is mostly to reduce path size for command-line limits on windows if(WIN32) # This seems to break Xcode projects so definitely don't enable on Apple builds set(CMAKE_USE_RELATIVE_PATHS true) set(CMAKE_SUPPRESS_REGENERATION true) endif() # Include necessary submodules set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) ##################################################################### # Set up the basic build environment ##################################################################### if (CMAKE_BUILD_TYPE STREQUAL "") # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up # differentiation between debug and release builds. set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) endif () if (NOT APPLE) # Create debug libraries with _d postfix set(CMAKE_DEBUG_POSTFIX "_d") endif () if (MSVC) if (CMAKE_BUILD_TOOL STREQUAL "nmake") # set variable to state that we are using nmake makefiles set(NMAKE TRUE) endif () set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast") # Enable intrinsics on MSVC in debug mode set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Oi") if (CMAKE_CL_64) # Visual Studio bails out on debug builds in 64bit mode unless # this flag is set... set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj") endif () if (MSVC_VERSION GREATER 1600 OR MSVC_VERSION EQUAL 1600) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif () endif () if (WIN32) if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # Specify build paths set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${NewtonSDK_BINARY_DIR}/lib") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${NewtonSDK_BINARY_DIR}/lib") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${NewtonSDK_BINARY_DIR}/bin") # We don't want to install in default system location, install is really for the SDK, so call it that set(CMAKE_INSTALL_PREFIX "${NewtonSDK_SOURCE_DIR}/sdk" CACHE PATH "Newton SDK install directory prefix" FORCE) endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) endif () # install dirs # choose right place on UNIX if (UNIX) include("GNUInstallDirs") else (UNIX) set(CMAKE_INSTALL_LIBDIR "lib") set(CMAKE_INSTALL_BINDIR "bin") set(CMAKE_INSTALL_INCLUDEDIR "include") endif (UNIX) ################################################################### # disable (useless) compiler warnings on project level ################################################################### if(MSVC) add_definitions( /wd4786 /wd4503 /wd4251 /wd4275 /wd4290 /wd4661 /wd4996 /wd4127 /wd4100 -D_SILENCE_AMP_DEPRECATION_WARNINGS) endif() # determine if we are compiling for a 32bit or 64bit system include(CheckTypeSize) CHECK_TYPE_SIZE("void*" PTR_SIZE BUILTIN_TYPES_ONLY) if (PTR_SIZE EQUAL 8) set(BUILD_64 TRUE) else () set(BUILD_64 FALSE) endif () # Options if (MSVC) option(NEWTON_INSTALL_PDB "Install debug pdb files" OFF) endif(MSVC) option ("NEWTON_BUILD_STATIC" "All static" ON) option ("NEWTON_DISABLE_ASSERT" "No assert" OFF) option ("NEWTON_DEMOS" "Build demos Sandbox" OFF) option ("NEWTON_USE_DOUBLE" "Use double precision" OFF) add_subdirectory("${NewtonSDK_SOURCE_DIR}/coreLibrary_300") add_subdirectory("${NewtonSDK_SOURCE_DIR}/packages") if (NEWTON_DEMOS) add_subdirectory("${NewtonSDK_SOURCE_DIR}/applications/demosSandbox") endif(NEWTON_DEMOS) if (MSVC) if (NEWTON_INSTALL_PDB) FILE(GLOB pdbFiles "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/*.pdb") install(FILES ${pdbFiles} DESTINATION ${CMAKE_INSTALL_LIBDIR} CONFIGURATIONS Debug) endif (NEWTON_INSTALL_PDB) endif (MSVC)