fixes cmake for mac, adds define option for building tests

This commit is contained in:
Sam Hatchett
2018-06-06 18:14:36 -05:00
parent 80a0acc26b
commit 9520b6d253

View File

@@ -1,27 +1,26 @@
# CMakeLists.txt - CMake configuration file for EPANET 2.0 # CMakeLists.txt - CMake configuration file for EPANET 2.0
# #
# CMake is a cross-platform build tool. CMake generates platform native # CMake is a cross-platform build tool. CMake generates platform native
# makefiles that can be used with your compiler of choice. CMake uses a # makefiles that can be used with your compiler of choice. CMake uses a
# generator concept to represent different build tooling. CMake automatically # generator concept to represent different build tooling. CMake automatically
# detects the platform it is running on and generates the appropriate makefiles # detects the platform it is running on and generates the appropriate makefiles
# for the platform default compiler. Different generators can also be specified. # for the platform default compiler. Different generators can also be specified.
# #
# Note: CMake requires that your platform build system and compiler are # Note: CMake requires that your platform build system and compiler are
# properly installed. Build using Visual Studio requires msbuild shell. # properly installed. Build using Visual Studio requires msbuild shell.
# #
# Example Usage: # Example Usage:
# cd build/cmake
# mkdir buildproducts # mkdir buildproducts
# cd buildproducts # cd buildproducts
# cmake .. # cmake ..
# make # make
# #
# Building MSYS on Windows: # Building MSYS on Windows:
# ... # ...
# cmake -G "MSYS Makefiles" .. # cmake -G "MSYS Makefiles" ..
# make # make
# #
# Building Visual Studio on Windows: # Building Visual Studio on Windows:
# ... # ...
# cmake -G "Visual Studio 10 2010" .. # cmake -G "Visual Studio 10 2010" ..
# msbuild /p:Configuration=Release ALL_BUILD.vcxproj # msbuild /p:Configuration=Release ALL_BUILD.vcxproj
@@ -29,23 +28,25 @@
# Generic Invocation: # Generic Invocation:
# cmake -E make_directory buildprod # cmake -E make_directory buildprod
# cd build # cd build
# cmake -G GENERATOR -DCMAKE_BUILD_TYPE=Release .. # cmake -G GENERATOR -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=1 ..
# cmake --build . --target SOME_TARGET --config Release # cmake --build . --target SOME_TARGET --config Release
# #
# More information: # More information:
# cmake --help # cmake --help
# #
# CMake is available at https://cmake.org/download/ # CMake is available at https://cmake.org/download/
# #
cmake_minimum_required (VERSION 2.8.8) cmake_minimum_required (VERSION 2.8.8)
project(EPANET) project(EPANET)
add_subdirectory(tools/epanet-output) add_subdirectory(tools/epanet-output)
add_subdirectory(tests)
IF (BUILD_TESTS)
add_subdirectory(tests)
ENDIF (BUILD_TESTS)
# Sets for output directory for executables and libraries. # Sets for output directory for executables and libraries.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
@@ -55,8 +56,8 @@ SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
IF (APPLE) IF (APPLE)
SET(CMAKE_INSTALL_NAME_DIR @executable_path) SET(INSTALL_NAME_DIR @executable_path/../lib)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH ON) SET(CMAKE_MACOSX_RPATH 1)
ENDIF (APPLE) ENDIF (APPLE)
IF (MSVC) IF (MSVC)
@@ -89,8 +90,8 @@ target_include_directories(epanet PUBLIC ${PROJECT_SOURCE_DIR}/include)
# EXPORT_MACRO_NAME DLLEXPORT # EXPORT_MACRO_NAME DLLEXPORT
# EXPORT_FILE_NAME epanet_export.h # EXPORT_FILE_NAME epanet_export.h
# STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC) # STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC)
# #
#file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_export.h #file(COPY ${CMAKE_CURRENT_BINARY_DIR}/epanet_export.h
# DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include) # DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include)