gangliao / cmake_cxx_go Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
I have a library client
in folder ./client
, and have an executable I want to build in folder ./client/test
. But when doing make
, it reports can not find header file (the header file is generated when doing go build
).
./CMakeLists.txt:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
cmake_minimum_required(VERSION 3.0)
project(cxx_go C Go)
include(cmake/golang.cmake)
include(cmake/flags.cmake)
add_subdirectory(client)
add_subdirectory(client/test)
./client/CMakeLists.txt:
ExternalGoProject_Add(pserver github.com/PaddlePaddle/Paddle/paddle/go/pserver)
add_go_library(client STATIC pserver)
./client/test/CMakeList.txt:
#include_directories(/home/helin/env/gopath/src/github.com/PaddlePaddle/Paddle/paddle/go/pserver/lib/build/client)
add_executable(main main.c)
add_dependencies(main client)
set (CMAKE_EXE_LINKER_FLAGS "-pthread")
#target_link_libraries(main /home/helin/env/gopath/src/github.com/PaddlePaddle/Paddle/paddle/go/pserver/lib/build/client/libclient.a)
target_link_libraries(main)
If I un-comment the two lines in above file, it could work. But how can I not hard code absolute path into the cmake file?
$ rm -rf * ; cmake .. && make -j12
-- The CXX compiler identification is AppleClang 8.1.0.8020042
-- The C compiler identification is AppleClang 8.1.0.8020042
-- The Golang compiler identification is go1.8.1 darwin/amd64
-- Check for working Golang compiler: /usr/local/bin/go
-- 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
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/cmake_cxx_go/build
Scanning dependencies of target main
Scanning dependencies of target adder
Scanning dependencies of target go_redis
make[2]: *** No rule to make target `src/static_and_shared/libadder.a', needed by `src/static_and_shared/main'. Stop.
make[2]: *** Waiting for unfinished jobs....
[ 50%] Building CXX object src/static_and_shared/CMakeFiles/main.dir/main.cxx.o
[ 50%] Generating /.timestamp
/tmp/cmake_cxx_go/src/static_and_shared/main.cxx:1:10: fatal error: 'libadder.h' file not found
#include "libadder.h"
^
1 error generated.
make[2]: *** [src/static_and_shared/CMakeFiles/main.dir/main.cxx.o] Error 1
make[1]: *** [src/static_and_shared/CMakeFiles/main.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 50%] Built target go_redis
[ 50%] Built target adder
make: *** [all] Error 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.