sparrowresource included in cmake
This commit is contained in:
parent
8f6ebade36
commit
4191691e84
@ -1,20 +0,0 @@
|
||||
project(TestTemplate)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
sparrow_input
|
||||
PREFIX ${PROJECT_SOURCE_DIR}/..
|
||||
GIT_REPOSITORY Lendemor:lum1ere%40@https://git.epicsparrow.com/epicsparrow/SparrowInput.git
|
||||
)
|
||||
|
||||
EXTERNALProject_get_property(sparrow_input install_dir)
|
||||
|
||||
MESSAGE(STATUS ${install_dir})
|
||||
|
||||
add_library(sparrow_input)
|
||||
|
||||
include(template.cmake)
|
||||
|
||||
|
22
resource.cmake
Normal file
22
resource.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
# Subfile for cmaketemplate :
|
||||
# Generate a .cpp file with given resource file
|
||||
#
|
||||
|
||||
include_directories(
|
||||
${CMAKE_TEMPLATE_PATH}/resource #bad but necessary for resource.h
|
||||
)
|
||||
|
||||
add_executable(SparrowResource ${CMAKE_TEMPLATE_PATH}/resource/main.cpp)
|
||||
|
||||
#SET (RESOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}${RESOURCE_DIRS})
|
||||
#MESSAGE(${RESOURCE_PATH})
|
||||
|
||||
#SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DST_FILE}
|
||||
COMMAND SparrowResource
|
||||
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DST_FILE} ${RES_SRC_FILE}
|
||||
DEPENDS ${RES_SRC_FILE}
|
||||
COMMENT "Generating resource file"
|
||||
)
|
@ -1,8 +1,10 @@
|
||||
project(SparrowResource)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_TEMPLATE_PATH "..")
|
||||
|
||||
# choose source file
|
||||
set(EXEC_SRC_LIST main.cpp)
|
||||
|
||||
include(../template.cmake)
|
||||
include(${CMAKE_TEMPLATE_PATH}/template.cmake)
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
Hello World !
|
@ -13,8 +13,17 @@ set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
if(NOT CMAKE_TEMPLATE_PATH)
|
||||
MESSAGE(WARNING "CMAKE_TEMPLATE_PATH not set. Using default value \"../cmaketemplate\"...")
|
||||
SET(CMAKE_TEMPLATE_PATH "../cmaketemplate")
|
||||
endif()
|
||||
|
||||
include(${CMAKE_TEMPLATE_PATH}/resource.cmake)
|
||||
|
||||
MESSAGE(${PROJECT_BINARY_DIR})
|
||||
|
||||
configure_file (
|
||||
"../cmaketemplate/SparrowConfig.h.in"
|
||||
"${CMAKE_TEMPLATE_PATH}/SparrowConfig.h.in"
|
||||
"${PROJECT_BINARY_DIR}/Version.h"
|
||||
)
|
||||
|
||||
@ -356,7 +365,7 @@ endif()
|
||||
|
||||
include_directories(
|
||||
${INCLUDE_PATHS}
|
||||
${EXTRA_INCLUDE}
|
||||
${EXTRA_INCLUDES}
|
||||
)
|
||||
|
||||
if(LIB_SRC_LIST)
|
||||
|
17
test/CMakeLists.txt
Normal file
17
test/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
project(SparrowTest)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(CMAKE_TEMPLATE_PATH "..")
|
||||
|
||||
#SET(RESOURCE_DIRS /shaders)
|
||||
|
||||
#SET(RES_SRC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/plop.txt ${CMAKE_CURRENT_SOURCE_DIR}/plop2.txt)
|
||||
FILE(GLOB RES_SRC_FILE plop.txt plop2.txt)
|
||||
SET(RESOURCE_DST_FILE res.cpp)
|
||||
|
||||
MESSAGE(${RES_SRC_FILE})
|
||||
|
||||
# choose source file
|
||||
set(EXEC_SRC_LIST test.cpp ${RESOURCE_DST_FILE})
|
||||
|
||||
include(${CMAKE_TEMPLATE_PATH}/template.cmake)
|
1
test/plop.txt
Normal file
1
test/plop.txt
Normal file
@ -0,0 +1 @@
|
||||
Hello World !
|
2
test/plop2.txt
Normal file
2
test/plop2.txt
Normal file
@ -0,0 +1,2 @@
|
||||
This is a tessst
|
||||
fefea
|
30
test/res.cpp
Normal file
30
test/res.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Resource {
|
||||
std::unordered_map<std::string, const char*> *resourceFilesData;
|
||||
|
||||
const char data0[] = {
|
||||
0x48,0x65,0x6c,0x6c,0x6f,0x20,0x57,0x6f,0x72,0x6c,0x64,0x20,0x21,0xa
|
||||
};
|
||||
|
||||
const char data1[] = {
|
||||
0x54,0x68,0x69,0x73,0x20,0x69,0x73,0x20,0x61,0x20,0x74,0x65,0x73,0x73,0x73,0x74,0xa,0x66,0x65,0x66,0x65,0x61,0xa
|
||||
};
|
||||
|
||||
void initResourceData()
|
||||
{
|
||||
resourceFilesData = new std::unordered_map<std::string, const char*>();
|
||||
(*resourceFilesData)["/data/Qt_workspace/cmaketemplate/test/plop.txt"] = data0;
|
||||
(*resourceFilesData)["/data/Qt_workspace/cmaketemplate/test/plop2.txt"] = data1;
|
||||
|
||||
}
|
||||
|
||||
const char* get(const std::string &fileName)
|
||||
{
|
||||
if(resourceFilesData->count(fileName) > 0)
|
||||
return (*resourceFilesData)[fileName];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#include <iostream>
|
||||
#include "resource.h"
|
||||
#include "../resource/resource.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -7,9 +7,9 @@ int main()
|
||||
{
|
||||
cout << "Resource test" << endl;
|
||||
Resource::initResourceData();
|
||||
const char *str = Resource::get("plop.txt");
|
||||
const char *str = Resource::get("/data/Qt_workspace/cmaketemplate/test/plop.txt");
|
||||
if(str != NULL)
|
||||
cout << str << endl;
|
||||
else
|
||||
cout << "nope" << endl;
|
||||
}
|
||||
}
|
BIN
test/test.exe
Normal file
BIN
test/test.exe
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user