Permalink
Browse files

added Windows support

  • Loading branch information...
Stefan Sicklinger
Stefan Sicklinger committed Dec 21, 2013
1 parent 14a2990 commit 201ff51333af76e17b793c28edfbb530b9bc83a5
Showing with 112 additions and 37 deletions.
  1. +54 −30 CMakeLists.txt
  2. +16 −4 Emperor/CMakeLists.txt
  3. +7 −2 Emperor/src/CMakeLists.txt
  4. +6 −1 cmake/modules/FindMKL.cmake
  5. +29 −0 configure/batch_config
@@ -21,10 +21,14 @@
project (EMPIRE)
#------------------------------------------------------------------------------------#
cmake_minimum_required (VERSION 2.8.10)
enable_language(Fortran OPTIONAL)
#------------------------------------------------------------------------------------#
IF(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64"))
MESSAGE(FATAL_ERROR "EMPIRE is supported on Linux x86_64 only")
IF( (${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64"))
enable_language(Fortran OPTIONAL)
MESSAGE("EMPIRE is going to be configured for Linux x86_64!")
ELSEIF( (${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "AMD64"))
MESSAGE("EMPIRE is going to be configured for Windows x64!")
ELSE()
MESSAGE(FATAL_ERROR "EMPIRE is supported on Linux x86_64 and Windows x64 only")
ENDIF()
#------------------------------------------------------------------------------------#
# 1. Options
@@ -46,8 +50,9 @@ ENDIF()
######################################################################################
#1. Option
######################################################################################
option(USE_INTEL_COMPILERS_AND_MKL "Use Intel Compilers C/C++ and MKL" ON )
option(BUILD_FORTRAN_CLIENTS "This builds FORTRAN test clients" OFF )
#option(USE_INTEL_COMPILERS_MKL_IMPI "Use Intel Compilers C/C++, Intel MKL and Intel MPI" ON )
#option(USE_MICROSOFT_COMPILERS_MKL_IMPI "Use Microsoft Compilers C/C++, Intel MKL and Intel MPI" OFF )
option(BUILD_FORTRAN_CLIENTS "This builds FORTRAN test clients" OFF )
######################################################################################
#2. Macros
######################################################################################
@@ -67,58 +72,77 @@ include(CheckCXXCompilerFlag)
# Avoid in source builds
macro_ensure_out_of_source_build("In source build is not allowed for ${PROJECT_NAME}. Please run CMake from your build directory. You may want to remove CMakeCache.txt.")
#------------------------------------------------------------------------------------#
# Check compilers and their versions
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND "${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
# using Intel C/C++
SET(USE_INTEL_COMPILERS_MKL_IMPI_LINUX ON)
MESSAGE("C compiler is ${CMAKE_C_COMPILER_ID} and has version ${CMAKE_C_COMPILER_VERSION} \nC++ compiler is ${CMAKE_CXX_COMPILER_ID} and has version ${CMAKE_CXX_COMPILER_VERSION} " )
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
# using MSVC
SET(USE_INTEL_COMPILERS_MKL_MSMPI_WINDOWS ON)
MESSAGE("C compiler is ${CMAKE_C_COMPILER_ID} and has version ${CMAKE_C_COMPILER_VERSION} \nC++ compiler is ${CMAKE_CXX_COMPILER_ID} and has version ${CMAKE_CXX_COMPILER_VERSION} " )
MESSAGE("As OpenMP 3.0 and VLA (C99) is used in EMPIRE you need to switch to Intel Compiler in Visual Studio" )
ELSE()
MESSAGE(FATAL_ERROR "Your CXX compiler is ${CMAKE_CXX_COMPILER_ID} and your C compiler is ${CMAKE_C_COMPILER_ID} they are not supported by the build system yet")
ENDIF()
#------------------------------------------------------------------------------------#
# Set Intel Compiler & MKL
IF (${USE_INTEL_COMPILERS_AND_MKL})
IF (${USE_INTEL_COMPILERS_MKL_IMPI_LINUX})
SET (CMAKE_C_COMPILER "mpiicc")
SET (CMAKE_CXX_COMPILER "mpiicpc")
#SET (MKL_INCLUDE_DIR "")
#SET (MKL_LIB_DIR "")
find_package(MKL REQUIRED)
#Let the source code know
add_definitions(-DUSE_INTEL_MKL)
#MESSAGE("MKL is set ${MKL_INCLUDE_DIRS} ${LIBS}")
add_definitions(-DUSE_INTEL_MKL)
ENDIF()
#------------------------------------------------------------------------------------#
# Check compilers and their versions
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
# using GNU
MESSAGE("compiler is GNU")
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND "${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
# using Intel C/C++
MESSAGE("C compiler is ${CMAKE_C_COMPILER_ID} and has version ${CMAKE_C_COMPILER_VERSION} \nC++ compiler is ${CMAKE_CXX_COMPILER_ID} and has version ${CMAKE_CXX_COMPILER_VERSION} " )
ELSE()
MESSAGE(FATAL_ERROR "Your compiler is not supported by the build system")

IF (${USE_INTEL_COMPILERS_MKL_MSMPI_WINDOWS})
# Require MPI for this project:
SET(MPI_ROOT_PATH "C:/Program Files/Microsoft HPC Pack 2012")
SET(MPI_CXX_INCLUDE_PATH "${MPI_ROOT_PATH}/Inc")
SET(MPI_CXX_LINK_FLAGS "${MPI_ROOT_PATH}/Lib/amd64/msmpi.lib")
#SET (MKL_INCLUDE_DIR "")
#SET (MKL_LIB_DIR "")
find_package(MKL REQUIRED)
#Let the source code know
add_definitions(-DUSE_INTEL_MKL)
ENDIF()


#------------------------------------------------------------------------------------#
# Global valid defines
add_definitions(-DFLANN) # TEMP
add_definitions(-DMPICH_IGNORE_CXX_SEEK)
#------------------------------------------------------------------------------------#
# Set Compiler flags and Linker flags (CMAKE_BUILD_TYPE is not used!)
## This is for all compilers
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 ")
## Here INTEL specific flags are taken care for
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND "${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
## This is for all compilers
check_c_compiler_flag(-xHost CHECKXHOST)
check_cxx_compiler_flag(-xHost CHECKXHOST)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xHost")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost")
SET (CMAKE_C_FLAGS "-xHost -std=c99")
SET (CMAKE_CXX_FLAGS "-xHost")
ENDIF()
## Here GNU specific flags are taken care for
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-result")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result")
## Here Intel Windows specific flags are taken care for
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
SET (CMAKE_C_FLAGS "/QxHost /Qstd=c99")
SET (CMAKE_CXX_FLAGS "/QxHost /Qstd=c++11")
ENDIF()
######################################################################################
#4. Configure
######################################################################################
configure_file("${PROJECT_SOURCE_DIR}/configure/bashrc_config" "${PROJECT_SOURCE_DIR}/etc/bashrc.sh")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
configure_file("${PROJECT_SOURCE_DIR}/configure/bashrc_config" "${PROJECT_SOURCE_DIR}/etc/bashrc.sh")
ENDIF()
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
configure_file("${PROJECT_SOURCE_DIR}/configure/batch_config" "${PROJECT_SOURCE_DIR}/etc/batch.bat")
ENDIF()
######################################################################################
#5. Subdirectories THE ORDER IS IMPORTANT
######################################################################################
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../EMPIRE-Libraries" "${CMAKE_CURRENT_BINARY_DIR}/EMPIRE-Libraries")
add_subdirectory(Emperor)
add_subdirectory(EMPIRE_API)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../EMPIRE-Testing" "${CMAKE_CURRENT_BINARY_DIR}/EMPIRE-Testing")
#add_subdirectory(EMPIRE_API)
#add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../EMPIRE-Testing" "${CMAKE_CURRENT_BINARY_DIR}/EMPIRE-Testing")

@@ -2,12 +2,24 @@
# Openmp parallelism
find_package(OpenMP 3.0 REQUIRED)
IF(OPENMP_FOUND)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
ENDIF()
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qopenmp")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Qopenmp")
ENDIF()
ENDIF(OPENMP_FOUND)
#------------------------------------------------------------------------------------#
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -C")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -C")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -C")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -C")
ENDIF()
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /C")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /C")
ENDIF()
#------------------------------------------------------------------------------------#
include_directories(${MKL_INCLUDE_DIR})
SET(Emperor_LIBS ${Emperor_LIBS} ${MKL_LIBRARIES})
@@ -16,18 +16,23 @@ get_property(Emperor_INCLUDES GLOBAL PROPERTY Emperor_INCLUDES)
get_property(Emperor_SOURCES GLOBAL PROPERTY Emperor_SOURCES)
get_property(EMPIRE_thirdparty_INCLUDES GLOBAL PROPERTY EMPIRE_thirdparty_INCLUDES)
#------------------------------------------------------------------------------------#
# MPI
IF(MPI_CXX_INCLUDE_PATH)
include_directories(${MPI_CXX_INCLUDE_PATH})
ENDIF()
#------------------------------------------------------------------------------------#
include_directories(${Emperor_INCLUDES})
include_directories(${EMPIRE_thirdparty_INCLUDES})
LIST(REMOVE_ITEM Emperor_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
add_library(EmperorLib STATIC ${Emperor_SOURCES} $<TARGET_OBJECTS:EMPIRE_thirdparty>)
#------------------------------------------------------------------------------------#
add_executable(Emperor ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
target_link_libraries(Emperor EmperorLib ${Emperor_LIBS})
target_link_libraries(Emperor EmperorLib ${Emperor_LIBS} ${MPI_CXX_LINK_FLAGS})
#------------------------------------------------------------------------------------#
add_dependencies(Emperor EmperorLib EMPIRE_thirdparty)
#------------------------------------------------------------------------------------#
MESSAGE("C Compiler Flags are:\t${CMAKE_C_FLAGS} \nC++ Compiler Flags are:\t${CMAKE_CXX_FLAGS}")
#MESSAGE("Emperor_LIBS: ${Emperor_LIBS}")
#MESSAGE("Emperor_INCLUDES: ${Emperor_INCLUDES}")
#MESSAGE("Emperor_SOURCES: ${Emperor_SOURCES}")
#------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------#
@@ -56,7 +56,12 @@ if (MKL_LIB_DIR)
find_library(MKL_INTEL_THREAD_LIBRARY mkl_intel_thread ${MKL_LIB_DIR})
find_library(MKL_CORE_LIBRARY mkl_core ${MKL_LIB_DIR})
if (MKL_INTEL_LP64_LIBRARY AND MKL_INTEL_THREAD_LIBRARY AND MKL_CORE_LIBRARY)
set (MKL_LIBRARIES "-Wl,--start-group ${MKL_INTEL_LP64_LIBRARY} ${MKL_INTEL_THREAD_LIBRARY} ${MKL_CORE_LIBRARY} -Wl,--end-group -lpthread")
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
set (MKL_LIBRARIES "-Wl,--start-group ${MKL_INTEL_LP64_LIBRARY} ${MKL_INTEL_THREAD_LIBRARY} ${MKL_CORE_LIBRARY} -Wl,--end-group -lpthread")
ENDIF()
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
set (MKL_LIBRARIES ""${MKL_INTEL_LP64_LIBRARY}" "${MKL_INTEL_THREAD_LIBRARY}" "${MKL_CORE_LIBRARY}"")
ENDIF()
else ()
set (MKL_LIBRARIES "")
endif ()
@@ -0,0 +1,29 @@
REM #Set EMPIRE environment
@echo off
set EMPIRE_CORE_BASE_DIR=@PROJECT_SOURCE_DIR@
REM ######################################################################################
REM # Set TOOLCHAIN and BASE DIR
REM
REM ######################################################################################
REM # Set PATH ENV variables for INCLUDE, LINKING and EXECUTION
set EMPIRE_API_LIB_NAME=EMPIRE_API
set EMPIRE_LD_LIBRARY_PATH=%EMPIRE_CORE_BASE_DIR%\lib
set EMPIRE_API_INC_ON_MACHINE=%EMPIRE_CORE_BASE_DIR%\EMPIRE_API\src\include\
set EMPIRE_API_LIB_ON_MACHINE=%EMPIRE_LD_LIBRARY_PATH%\lib$EMPIRE_API_LIB_NAME.a
set EMPIRE_API_LIBSO_ON_MACHINE=%EMPIRE_LD_LIBRARY_PATH%\lib$EMPIRE_API_LIB_NAME.dll
set EMP_PATH=$EMPIRE_CORE_BASE_DIR\bin:%EMP_PATH%
REM # INTEL MPI variables
set I_MPI_FABRICS=shm:tcp
set I_MPI_FAULT_CONTINUE=off
echo 'Setting toolchain ICC'
REM ######################################################################################
REM #Code metric
REM # Not support under WINDOWS
REM ######################################################################################
set PATH=%EMP_PATH%;%PATH%
REM set LD_LIBRARY_PATH=%EMPIRE_LD_LIBRARY_PATH%;%LD_LIBRARY_PATH%
REM ######################################################################################
echo 'EMPIRE environment is ready to use.'



0 comments on commit 201ff51

Please sign in to comment.