toeb / cmakepp

An Enhancement Suite for the CMake Build System
Other
436 stars 37 forks source link

cmakepp errors on MacOSX + bonus questions #129

Open roscopecoltran opened 7 years ago

roscopecoltran commented 7 years ago

Hi,

hope you are all well !

I tried to build the example, described on your blog (link), and I got the following errors.

  1. eigen3 is not included
  2. several CMake Warning

Errors:

  Cannot set "__ans": current scope has no parent.
Call Stack (most recent call first):
  /opt/local/share/cmake-3.7/Modules/Compiler/Clang.cmake:7 (return)
  /opt/local/share/cmake-3.7/Modules/Compiler/AppleClang-CXX.cmake:1 (include)
  /opt/local/share/cmake-3.7/Modules/CMakeCXXInformation.cmake:25 (include)
  cmakepp.cmake:5706 (_project)
  CMakeLists.txt:26 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at cmakepp.cmake:11098 (set):
  Cannot set "__ans": current scope has no parent.
Call Stack (most recent call first):
  /opt/local/share/cmake-3.7/Modules/Platform/Darwin-Clang.cmake:7 (return)
  /opt/local/share/cmake-3.7/Modules/Platform/Darwin-Clang-CXX.cmake:1 (include)
  /opt/local/share/cmake-3.7/Modules/Platform/Darwin-AppleClang-CXX.cmake:1 (include)
  /opt/local/share/cmake-3.7/Modules/CMakeCXXInformation.cmake:48 (include)
  cmakepp.cmake:5706 (_project)
  CMakeLists.txt:26 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
{
 "myproject":{
  "name":"myproject",
  "directory":"/Users/Luccio/cpp/cmakepp",
  "targets":{
   "name":"myexe",
   "project_name":"myproject"
  }
 }
}
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/Luccio/cpp/cmakepp/_builds
Scanning dependencies of target myexe
[ 50%] Building CXX object CMakeFiles/myexe.dir/main.cpp.o
/Users/Luccio/cpp/cmakepp/main.cpp:3:10: fatal error: 'Eigen/Dense' file not found
#include <Eigen/Dense>
         ^
1 error generated.
gmake[2]: *** [CMakeFiles/myexe.dir/build.make:63: CMakeFiles/myexe.dir/main.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/myexe.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2

CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.12)
## CMakeLists.txt for a simple project 
set(current_dir "${CMAKE_CURRENT_SOURCE_DIR}")
## get cmakepp
if(NOT EXISTS "${current_dir}/cmakepp.cmake")
  file(DOWNLOAD "https://github.com/toeb/cmakepp/releases/download/v0.3.1-alpha/cmakepp.cmake" "${current_dir}/cmakepp.cmake")
endif()

include("${current_dir}/cmakepp.cmake")

if(NOT EXISTS ${current_dir}/dependencies/eigen3)
 message(STATUS "installing Eigen3 from bitbucket")
 pull_package(eigen/eigen?tag=3.1.0 ${current_dir}/dependencies/eigen3)
 ans(package_handle)
 if(NOT package_handle)
  message(FATAL_ERROR "could not pull Eigen3")
 endif()
 ## print the package information returned
 json_print(${package_handle})

 message(STATUS "${current_dir}/dependencies/eigen3")

endif()

## from here on everything can be a normal cmakelists file
project(myproject)

include_directories("dependencies/eigen3")

fwrite("main.cpp" "
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
  MatrixXd m(2,2);
  m(0,0) = 3;
  m(1,0) = 2.5;
  m(0,1) = -1;
  m(1,1) = m(1,0) + m(0,1);
  std::cout << m << std::endl;
}
")
add_executable(myexe "main.cpp")

print_project_tree()
print_targets()

Is there any way to solve these issues ?

Bonus questions:

Did you ever thought or start to develop some toolchains management for cmakepp ?

My use case is aimed for building cross-platform unity3d plugins for iOS, Android, WSA, MacOSX and Linux of CMake driven project (eg. Tensorflow)

More precisely, it would be really cool to manage a list of toolchains like Polly and some dockerized transpilers like with Dockcross.

It would help to create a template through cmake, as I would like to create a build bot to replace such bash scripts:

#!/bin/bash

## ##################################################################################################################################
# Copyright (c) 2017, Rosco Pecoltran
# All rights reserved.
## ##################################################################################################################################

set -e

clear ## clear terminal screen
pwd ## check current workdir

## #################################################################
## Project SDK name
## #################################################################

if [ ! -z "$1" ]; then
    PROJECT_NAME="$1"  # Custom SDK name (eg. SnipAR in order to gather in on Unity3D project all packages build, per platforms)
else
    echo "[Sniper] No arguments supplied for output SDK name"
    PROJECT_NAME="Eigen3" # Default output SDK name
fi

## #################################################################
## Project CMake Arguments
## #################################################################

PROJECT_CMAKE_ARGS_FILE=$(basename "$0" .sh) # filename to source inside the sniper bots ENV/CMake args for cross-compilation build with polly
PROJECT_CMAKE_HOME="." # home directory hosting root CMakeLists.txt

## #################################################################
## Project Global Arguments
## #################################################################

PROJECT_BUILD_TYPE="Release" # Release/Debug
PROJECT_LIBRARY_TARGET="eigen3" # Target name, libname ouput

## #################################################################
## Project VCS settings
## #################################################################

PROJECT_VCS_URL="https://github.com/hunter-packages/eigen"
PROJECT_VCS_BRANCH="hunter-3.3.1"

# notes: build package 
# - common:
#  - iOS (static libs)
#    - Architectures: i386, x86_64
#  - MacOSX (shared libs)
#    - Architectures: i386, x86_64
#  - Android (shared libs)
#    - Architectures: armv7a, armv7a-neon, arm64-v8a, x86, x86-64, mips, mips64
# - extras:
#  - Apple Frameworks (shared libs): iOS, MacOSX

## #################################################################
## Project Sniper Bot - settings
## #################################################################

SNIPER_BOTS_SCRIPT="bundle-unity3d.sh" # script filename to use for creating the new bundle of libraries

# Prefix Path with All SNIPER Bots Scripts
SNIPER_WORKDIR_DIR=$(pwd)
SNIPER_BOTS_PREFIX_PATH="./scripts"
SNIPER_BOTS_COMMAND="${SNIPER_BOTS_PREFIX_PATH}/${SNIPER_BOTS_SCRIPT}"
chmod a+x ${SNIPER_BOTS_COMMAND}

# Note: 
#  - enable/disable global settings for those helepers, please check: ./config/_init_.sh
SNIPER_BOTS_CONFIG_HELPERS_PREFIX_PATH="./config"
SNIPER_BOTS_CONFIG_HELPERS_INIT="_init_.sh"

# load global configuration settings for sniper bots dependencies (Polly, Hunter)
. ${SNIPER_BOTS_CONFIG_HELPERS_PREFIX_PATH}/${SNIPER_BOTS_CONFIG_HELPERS_INIT}

## #################################################################
## project build common arguments
## #################################################################

# common flags
PROJECT_BUILD_EXAMPLES=OFF
PROJECT_BUILD_TESTS=OFF
PROJECT_BUILD_DOCS=OFF

# libprotobuf-lite
PROJECT_COMMON_BUILD_ARGS=\
(
    "HUNTER_CONFIGURATION_TYPES=${PROJECT_BUILD_TYPE}"
    # build
    "EIGEN_BUILD_BTL=OFF"
    "EIGEN_BUILD_PKGCONFIG=ON"
    "EIGEN_DEFAULT_TO_ROW_MAJOR=OFF"
    "EIGEN_SPLIT_LARGE_TESTS=ON"
    # tests
    "EIGEN_FAILTEST=${PROJECT_BUILD_TESTS}"
    "BUILD_TESTING=${PROJECT_BUILD_DOCS}"
    "EIGEN_TEST_SSE2=OFF"
    "EIGEN_TEST_SSE3=OFF"
    "EIGEN_TEST_SSSE3=OFF"
    "EIGEN_TEST_SSE4_1=OFF"
    "EIGEN_TEST_SSE4_2=OFF"
    "EIGEN_TEST_AVX=OFF"
    "EIGEN_TEST_FMA=OFF"
    "EIGEN_TEST_AVX512=OFF"
    "EIGEN_TEST_F16C=OFF"
    "EIGEN_TEST_ALTIVEC=OFF"
    "EIGEN_TEST_VSX=OFF"
    "EIGEN_TEST_NEON=OFF"
    "EIGEN_TEST_NEON64=OFF"
    "EIGEN_TEST_ZVECTOR=OFF"
    "EIGEN_TEST_OPENMP=OFF"
    "EIGEN_TEST_SSE2=OFF"
    "EIGEN_TEST_NO_EXPLICIT_VECTORIZATION=OFF"
    "EIGEN_TEST_X87=OFF"
    "EIGEN_TEST_32BIT=OFF"
    "EIGEN_TEST_SYCL=OFF"
)

# Apple Frameworks - iOS and MacOSX 
PROJECT_BUILD_ARGS_UNITY3D_APPLE_FRAMEWORKS=\
(
    "BUILD_SHARED_LIBS=ON"
)

# PROJECT_PUBLIC_HEADERS_PREFIX_PATH=""

# iOS armv7, arm64
PROJECT_BUILD_ARGS_UNITY3D_APPLE_IOS=\
(
    "BUILD_SHARED_LIBS=OFF"
)

# MacOSX i386, x86_64
PROJECT_BUILD_ARGS_UNITY3D_APPLE_OSX=\
(
    "BUILD_SHARED_LIBS=ON"
)

# Android arm
PROJECT_BUILD_ARGS_UNITY3D_ANDROID=\
(
    "BUILD_SHARED_LIBS=ON"
)

# Linux
PROJECT_BUILD_ARGS_UNITY3D_LINUX=\
(
    "BUILD_SHARED_LIBS=ON"
)

# Windows WSA / SDK8.1 / PhoneSDK8.1
PROJECT_BUILD_ARGS_UNITY3D_WSA=\
(
    "BUILD_SHARED_LIBS=ON"
)

## #################################################################
## project build - active platforms/toolchains
## #################################################################

SNIPER_BOT_QUEUE_DEV=(\
    # Apple
    UNITY3D_APPLE_OSX_FRAMEWORK=TRUE        
    UNITY3D_APPLE_IOS_FRAMEWORK=TRUE            
)

SNIPER_BOT_QUEUE=(\
    UNITY3D_APPLE_OSX_FRAMEWORK=TRUE
    UNITY3D_APPLE_MACOSX=TRUE
    UNITY3D_APPLE_IOS_FRAMEWORK=TRUE
    UNITY3D_APPLE_IOS=TRUE
    UNITY3D_ANDROID_ARMEABI_V7A_NEON=TRUE
    UNITY3D_ANDROID_ARMEABI_V7A=TRUE
    UNITY3D_ANDROID_ARM64_V8A=TRUE
    UNITY3D_ANDROID_X86=TRUE
    UNITY3D_ANDROID_X86_64=TRUE
    UNITY3D_ANDROID_MIPS=TRUE
    UNITY3D_ANDROID_MIPS64=TRUE
    UNITY3D_LINUX_X86=TRUE
    UNITY3D_LINUX_X86_64=TRUE
    UNITY3D_WSA_PHONESDK81_ARM=TRUE
    UNITY3D_WSA_PHONESDK81_X86=TRUE
    UNITY3D_WSA_SDK81_ARM=TRUE
    UNITY3D_WSA_SDK81_X86=TRUE
    UNITY3D_WSA_SDK81_X64=TRUE
    UNITY3D_WSA_UWP_ARM=TRUE
    UNITY3D_WSA_UWP_X86=TRUE
    UNITY3D_WSA_UWP_X64=TRUE
)

## #################################################################
## Sniper BOT mode
## #################################################################

if [ $# -eq 0 ]
  then
    echo "[Sniper] No arguments supplied"
fi

if [ ! -z "$2" ]; then
    PROJECT_ENV="$2"  # Custom SDK name (eg. SnipAR in order to gather in on Unity3D project all packages build, per platforms)
else
    echo "[Sniper] No arguments supplied for bot actions mode"
    PROJECT_ENV="BOT_MODE" # Default output SDK name
fi

## #################################################################
## project prepare and build
## #################################################################

if [ "$2" == "ENV_MODE" ]; then
    echo "[Sniper] CMake arguments loaded..."
else
    ${SNIPER_BOTS_COMMAND}  ${PROJECT_NAME} \
                            ${PROJECT_BUILD_TYPE} \
                            ${PROJECT_VCS_URL} \
                            ${PROJECT_VCS_BRANCH} \
                            ${PROJECT_CMAKE_ARGS_FILE} \
                            ${PROJECT_CMAKE_HOME} \
                            ${PROJECT_LIBRARY_TARGET} \
                            ${PROJECT_EXECUTABLE_TARGET}
fi

## #################################################################
## project extra post-build commands
## #################################################################

## Copy output to a cache repository (eg. Hunter)
## Push output to github repository

## #################################################################
## output library integration / symbolification
## #################################################################

## Execute unit tests and re-symbolofication

## #################################################################
## project build reports and analysis
## #################################################################

## Check additional issues related to project or project forks

#
#
#
#### END ############################################################################################################################ END ####

Have a great day !

Cheers, Richard