2 cmake_minimum_required(VERSION 3.4)
6 # message(STATUS "testprint: ${CMAKE_CXX_FLAGS}")
8 set(_CHARM_NETWORK_TYPE "multicore")
9 set(CHARM_NETWORK_TYPE "${_CHARM_NETWORK_TYPE}" CACHE STRING "Target network layer. ex: multicore/netlrts/pamilrts/verbs/mpi (Only effective before first configure. See CHARM_PLATFORM.)")
11 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
12 set(_CHARM_OS "darwin")
13 elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
16 set(_CHARM_OS "linux")
18 set(CHARM_OS "${_CHARM_OS}" CACHE STRING "Target operating system. ex: linux/darwin/win (Only effective before first configure. See CHARM_PLATFORM.)")
20 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
21 set(_CHARM_CPU "x86_64")
22 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc")
24 elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc")
26 elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm7")
27 set(_CHARM_CPU "arm7")
31 set(CHARM_CPU "${_CHARM_CPU}" CACHE STRING "Target CPU architecture. Can be blank. ex: x86_64/ppc/arm7 (Only effective before first configure. See CHARM_PLATFORM.)")
33 set(_CHARM_PLATFORM "${CHARM_NETWORK_TYPE}-${CHARM_OS}")
34 if(NOT "${CHARM_CPU}" STREQUAL "")
35 set(_CHARM_PLATFORM "${_CHARM_PLATFORM}-${CHARM_CPU}")
37 set(CHARM_PLATFORM "${_CHARM_PLATFORM}" CACHE STRING "Target platform tuplet. (Constructed from CHARM_NETWORK_TYPE, CHARM_OS, and CHARM_CPU if not specified.)")
39 set(_CHARM_BUILD_OPTIONS "")
41 option(CHARM_SMP "Enable shared-memory communication within a single multi-processor machine instead of message passing.")
43 list(APPEND _CHARM_BUILD_OPTIONS "smp")
46 set(_CHARM_COMPILER "")
47 set(CHARM_COMPILER "${_CHARM_COMPILER}" CACHE STRING "Compiler name as understood by the Charm++ build script. ex: gcc/clang/icc/mpicxx/pgcc/xlc")
49 set (_CHARM_BUILD_FLAGS "")
50 set (_CHARM_TARGET_OPTS "")
51 if(CMAKE_BUILD_TYPE STREQUAL "Release")
52 list(APPEND _CHARM_BUILD_FLAGS "--with-production")
53 elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
54 list(APPEND _CHARM_BUILD_FLAGS "--enable-charmdebug")
55 list(APPEND _CHARM_BUILD_FLAGS "--enable-error-checking")
56 list(APPEND _CHARM_TARGET_OPTS "-g")
57 elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
58 list(APPEND _CHARM_BUILD_FLAGS "--with-production")
59 list(APPEND _CHARM_BUILD_FLAGS "--enable-charmdebug")
60 list(APPEND _CHARM_BUILD_FLAGS "--enable-error-checking")
61 list(APPEND _CHARM_TARGET_OPTS "-g")
64 include(ExternalProject)
67 SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
68 CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build charm++ ${CHARM_PLATFORM} ${_CHARM_BUILD_OPTIONS} ${CHARM_COMPILER} --only-configure ${_CHARM_BUILD_FLAGS} ${_CHARM_TARGET_OPTS} ${CMAKE_CXX_FLAGS}
69 BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} -C tmp charm++ OPTS="${_CHARM_TARGET_OPTS} ${CMAKE_CXX_FLAGS}"
70 # INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} -C tmp install
71 # INSTALL_COMMAND true
73 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
76 ExternalProject_Get_Property(Charm++ BINARY_DIR)
78 get_directory_property(hasParent PARENT_DIRECTORY)
80 set(CHARMC_EXECUTABLE ${BINARY_DIR}/bin/charmc PARENT_SCOPE)
81 set(CMAKE_CHARM_COMPILER ${BINARY_DIR}/bin/charmc PARENT_SCOPE)